| 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
| |||||||||||||||||||||||||||||||||||||
| 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'
MC/DC0%0/1
shift() || 'short'
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||
| 40 | 3 | ▶ | if ( $style eq 'short' ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 41 | 3 | my ($f, $i) = $inch_q->get_feet_and_inches; | |||||||||||||||||||||||||||||||||||
| 42 | 3 | ▶ | return ( $f ? $f."'" : '' ) . ( $i ? $i.'"' : '' ) | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$f and $i
MC/DC0%0/2
$f and $i
$f
$i
Truth table0%0/3
A and B
A= $fB= $i
| |||||||||||||||||||||||||||||||||||||
| 46 | ( $f && $i ? ' and ' : '' ) . | ||||||||||||||||||||||||||||||||||||
| 47 | ( $i ? $i.' inches' : '' ) | ||||||||||||||||||||||||||||||||||||
| 48 | } else { | ||||||||||||||||||||||||||||||||||||
| 49 | 0 | carp "Unknown format $style"; | |||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||
| 53 | 1 | 1; | |||||||||||||||||||||||||||||||||||