line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
### Change History |
2
|
|
|
|
|
|
|
# 1999-02-21 Created. -Simon |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Data::Quantity::Size::Inches; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require 5; |
7
|
1
|
|
|
1
|
|
8940
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
8
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
72
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use vars qw( $VERSION ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
129
|
|
11
|
|
|
|
|
|
|
$VERSION = 0.001; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
670
|
use Data::Quantity::Number::Number '-isasubclass'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# undef = Data::Quantity::Size::Inches->scale(); |
16
|
|
|
|
|
|
|
sub scale { |
17
|
0
|
|
|
0
|
0
|
0
|
return 'Inches'; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# ($f, $i) = $inch_q->get_feet_and_inches; |
21
|
|
|
|
|
|
|
sub get_feet_and_inches { |
22
|
3
|
|
|
3
|
0
|
5
|
my $inch_q = shift; |
23
|
3
|
|
|
|
|
10
|
my $count = $inch_q->value; |
24
|
3
|
|
|
|
|
15
|
my @values = ( int($count / 12), ($count % 12) ); |
25
|
3
|
50
|
|
|
|
13
|
return wantarray ? @values : \@values; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# $inch_q->set_feet_and_inches($f, $i); |
29
|
|
|
|
|
|
|
sub set_feet_and_inches { |
30
|
0
|
|
|
0
|
0
|
0
|
my $inch_q = shift; |
31
|
0
|
|
|
|
|
0
|
my ($f, $i) = @_; |
32
|
0
|
|
|
|
|
0
|
$inch_q->value( ($f * 12) + $i ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# $string = $quantity->readable($style) |
36
|
|
|
|
|
|
|
sub readable { |
37
|
3
|
|
|
3
|
0
|
12
|
my $inch_q = shift; |
38
|
3
|
|
50
|
|
|
18
|
my $style = shift || 'short'; |
39
|
|
|
|
|
|
|
|
40
|
3
|
50
|
|
|
|
9
|
if ( $style eq 'short' ) { |
|
|
0
|
|
|
|
|
|
41
|
3
|
|
|
|
|
9
|
my ($f, $i) = $inch_q->get_feet_and_inches; |
42
|
3
|
100
|
|
|
|
29
|
return ( $f ? $f."'" : '' ) . ( $i ? $i.'"' : '' ) |
|
|
100
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} elsif ( $style eq 'long' ) { |
44
|
0
|
|
|
|
|
|
my ($f, $i) = $inch_q->get_feet_and_inches; |
45
|
0
|
0
|
0
|
|
|
|
return ( $f ? $f." feet" : '' ) . |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
46
|
|
|
|
|
|
|
( $f && $i ? ' and ' : '' ) . |
47
|
|
|
|
|
|
|
( $i ? $i.' inches' : '' ) |
48
|
|
|
|
|
|
|
} else { |
49
|
0
|
|
|
|
|
|
carp "Unknown format $style"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |