File Coverage

blib/lib/Data/Quantity/Abstract/Base.pm
Criterion Covered Total %
statement 27 31 87.1
branch 2 2 100.0
condition 3 6 50.0
subroutine 7 11 63.6
pod 0 5 0.0
total 39 55 70.9


line stmt bran cond sub pod time code
1             package Data::Quantity::Abstract::Base;
2              
3             require 5;
4 6     6   32 use strict;
  6         10  
  6         195  
5 6     6   28 use Carp;
  6         9  
  6         459  
6 6     6   31 use Exporter;
  6         41  
  6         250  
7              
8 6     6   41 use vars qw( $VERSION );
  6         10  
  6         1911  
9             $VERSION = 0.001;
10              
11             # $quantity = Data::Quantity::Subclass->new( @_ );
12             sub new {
13 41     41 0 406 my $class_or_item = shift;
14 41   33     180 my $class = ref $class_or_item || $class_or_item;
15 41         187 my $quantity = $class->new_instance;
16 41         181 $quantity->init( @_ );
17 41         219 return $quantity;
18             }
19              
20             # $empty_q = Data::Quantity::Subclass->new_instance();
21             sub new_instance {
22 0     0 0 0 croak "abstract";
23             }
24              
25             # $quantity->init( @_ );
26             sub init {
27 0     0 0 0 croak "abstract";
28             }
29              
30             sub value {
31 0     0 0 0 croak "abstract";
32             }
33              
34             sub scale {
35 0     0 0 0 croak "abstract";
36             }
37              
38              
39             sub import {
40 37     37   137 my $class = shift;
41            
42 37 100 66     535 if ( scalar @_ == 1 and $_[0] eq '-isasubclass' ) {
43 25         36 shift;
44 25         79 my $target_class = ( caller )[0];
45 6     6   35 no strict;
  6         9  
  6         750  
46 25         48 push @{"$target_class\::ISA"}, $class;
  25         629  
47             }
48            
49 37         20731 $class->SUPER::import( @_ );
50             }
51              
52              
53             1;