Quantity/Size/Inches.pm

filter: Statementstmt 77.4% 24 / 31 Branchbran 37.5% 6 / 16 Conditioncond 20.0% 1 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 4 totaltotal 55.2% 37 / 67 CC 11 SCAR 28.8
CC
11
Cov
60%
readable
30.8
get_feet_and_inches
2.0
scale
2.0
CRAP 17.8
« Quantity/Time/Date.pm ↑ Summary Quantity/Finance/Currency/USD.pm »
1 ### Change History
2 # 1999-02-21 Created. -Simon
3  
4 package Data::Quantity::Size::Inches;
5  
6 1 require 5;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 $VERSION = 0.001;
12  
13 1 ▶use Data::Quantity::Number::Number '-isasubclass';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # undef = Data::Quantity::Size::Inches->scale();
16 0 ▶sub scale {
Subroutine scale: not called CC=1 SCAR=6.9
Pod undocumented
17 0 return 'Inches';
18 }
19  
20 # ($f, $i) = $inch_q->get_feet_and_inches;
21 3 ▶sub get_feet_and_inches {
Subroutine get_feet_and_inches: called CC=2 SCAR=7.0
Pod undocumented
22 3 my $inch_q = shift;
23 3 my $count = $inch_q->value;
24 3 my @values = ( int($count / 12), ($count % 12) );
25 3 ▶ return wantarray ? @values : \@values;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3 0 3
26 }
27  
28 # $inch_q->set_feet_and_inches($f, $i);
29 0 ▶sub set_feet_and_inches {
Subroutine set_feet_and_inches: not called CC=1 SCAR=6.9
Pod undocumented
30 0 my $inch_q = shift;
31 0 my ($f, $i) = @_;
32 0 $inch_q->value( ($f * 12) + $i );
33 }
34  
35 # $string = $quantity->readable($style)
36 3 ▶sub readable {
Subroutine readable: called CC=10 SCAR=34.3
Pod undocumented
37 3 my $inch_q = shift;
38 3 ▶ my $style = shift || 'short';
Condition50%1/2
shift() || 'short'
l!l
03
MC/DC0%0/1
shift() || 'short'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
39
40 3 ▶ if ( $style eq 'short' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($style eq 'short') { } 3 0 3
elsif ($style eq 'long') { } 0 0 0
41 3 my ($f, $i) = $inch_q->get_feet_and_inches;
42 3 ▶ return ( $f ? $f."'" : '' ) . ( $i ? $i.'"' : '' )
Branch: 2 branches
BranchTrueFalseTotal
$f ? : 2 1 3
$i ? : 2 1 3
43 } elsif ( $style eq 'long' ) {
44 0 my ($f, $i) = $inch_q->get_feet_and_inches;
45 0 ▶ return ( $f ? $f." feet" : '' ) .
Branch: 3 branches
BranchTrueFalseTotal
$f ? : 0 0 0
$f && $i ? : 0 0 0
$i ? : 0 0 0
Condition0%0/3
$f and $i
!ll&&!rl&&r
000
MC/DC0%0/2
$f and $i
$f $i
Truth table0%0/3
A and B
A= $fB= $i
ABresult
0X0
100
111
46 ( $f && $i ? ' and ' : '' ) .
47 ( $i ? $i.' inches' : '' )
48 } else {
49 0 carp "Unknown format $style";
50 }
51 }
52  
53 1 1;
« Quantity/Time/Date.pm ↑ Summary Quantity/Finance/Currency/USD.pm »