File Coverage

blib/lib/Data/Quantity/Number/Integer.pm
Criterion Covered Total %
statement 22 29 75.8
branch 2 4 50.0
condition n/a
subroutine 6 8 75.0
pod 0 4 0.0
total 30 45 66.6


line stmt bran cond sub pod time code
1             ### Change History
2             # 1999-08-13 Added padding
3             # 1999-02-21 Created. -Simon
4              
5             package Data::Quantity::Number::Integer;
6              
7             require 5;
8 4     4   23 use strict;
  4         7  
  4         130  
9 4     4   20 use Carp;
  4         9  
  4         264  
10              
11 4     4   19 use vars qw( $VERSION );
  4         6  
  4         215  
12             $VERSION = 0.001;
13              
14 4     4   2446 use Data::Quantity::Number::Number '-isasubclass';
  4         10  
  4         39  
15              
16             # $previous_q = $quantity->previous;
17             # $next_q = $quantity->previous( $incr );
18             sub previous {
19 4     4 0 6 my $quantity = shift;
20 4         15 my $clone = $quantity->new_instance;
21 4 50       8 my $incr = scalar(@_) ? shift : 1;
22 4         10 $clone->value( $quantity->value - $incr );
23 4         15 return $clone;
24             }
25              
26             # $next_q = $quantity->next;
27             # $next_q = $quantity->next( $incr );
28             sub next {
29 3     3 0 6 my $quantity = shift;
30 3         7 my $clone = $quantity->new_instance;
31 3 50       8 my $incr = scalar(@_) ? shift : 1;
32 3         7 $clone->value( $quantity->value + $incr );
33 3         11 return $clone;
34             }
35              
36             # $padded = $quantity->zero_padded( $positions );
37             sub zero_padded {
38 0     0 0   my $quantity = shift;
39 0           my $value = $quantity->value;
40 0           my $places = shift;
41 0           return ( '0' x ( $places - length($value) ) ) . $value;
42             }
43              
44             # $padded = $quantity->zero_padded_value( $value, $positions );
45             sub zero_padded_value {
46 0     0 0   my $quantity = shift;
47 0           my ($value, $places) = @_;
48 0           return ( '0' x ( $places - length($value) ) ) . $value;
49             }
50              
51             1;