File Coverage

blib/lib/Audio/Nama/Lat.pm
Criterion Covered Total %
statement 24 25 96.0
branch 3 4 75.0
condition 1 3 33.3
subroutine 8 9 88.8
pod 0 5 0.0
total 36 46 78.2


line stmt bran cond sub pod time code
1             package Audio::Nama::Lat;
2 2     2   34831 use Modern::Perl;
  2         13479  
  2         15  
3             our @ISA;
4 2     2   296 use Data::Dumper::Concise;
  2         4  
  2         249  
5             use overload '+' => \&add_latency,
6 2     2   12 "\"\"" => sub { join ' ',$_[0]->min, $_[0]->max };
  2     5   3  
  2         1227  
  5         881  
7             sub new {
8 7     7 0 23 my $class = shift;
9 7         9 my ($min, $max) = @_;
10 7 50 33     37 defined $min and defined $max or die "undefined field: min: $min or max; $max";
11 7 100       28 die "Lat object has Min ($min) greater than Max ($max)" if $min > $max;
12 6         14 my $self = bless [$min, $max], $class;
13 6         22 $self;
14             }
15             sub add_latency {
16 2     2 0 7 my (@latencies) = @_[0,1]; # throw away swap argument
17 2         3 my ($min, $max) = (0,0);
18 2         4 map{ $min += $_->min; $max += $_->max } @latencies;
  4         8  
  4         10  
19 2         6 Audio::Nama::Lat->new($min, $max);
20             }
21 10     10 0 189 sub min {$_[0]->[0] }
22 9     9 0 40 sub max {$_[0]->[1] }
23 0     0 0   sub values { $_[0]->min, $_[0]->max }
24              
25             1;
26             __END__