line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Calc::Units::Convert::Byte; |
2
|
1
|
|
|
1
|
|
5
|
use base 'Math::Calc::Units::Convert::Base2Metric'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
614
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
356
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
my %units = ( bit => [ 1/8, 'byte' ] ); |
6
|
|
|
|
|
|
|
my %pref = ( bit => 0.1, default => 1 ); |
7
|
|
|
|
|
|
|
my %ranges = ( default => [ 1, 999 ] ); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my %total_unit_map; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub major_pref { |
12
|
2
|
|
|
2
|
0
|
10
|
return 1; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub major_variants { |
16
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
17
|
0
|
|
|
|
|
0
|
return $self->variants('byte'); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_ranges { |
21
|
210
|
|
|
210
|
0
|
463
|
return \%ranges; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub get_prefs { |
25
|
210
|
|
|
210
|
0
|
469
|
return \%pref; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub unit_map { |
29
|
163
|
|
|
163
|
0
|
211
|
my ($self) = @_; |
30
|
163
|
100
|
|
|
|
364
|
if (keys %total_unit_map == 0) { |
31
|
1
|
|
|
|
|
1
|
%total_unit_map = (%{$self->SUPER::unit_map()}, %units); |
|
1
|
|
|
|
|
9
|
|
32
|
|
|
|
|
|
|
} |
33
|
163
|
|
|
|
|
398
|
return \%total_unit_map; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
653
|
|
|
653
|
0
|
1362
|
sub canonical_unit { return 'byte'; } |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
2
|
0
|
9
|
sub abbreviated_canonical_unit { return 'B'; } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# simple_convert : unitName x unitName -> multiplier |
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
sub simple_convert { |
43
|
294
|
|
|
294
|
0
|
472
|
my ($self, $from, $to) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# 'b', 'byte', or 'bytes' |
46
|
294
|
100
|
|
|
|
1105
|
return 1 if $from =~ /^b(yte(s?))?$/i; |
47
|
|
|
|
|
|
|
|
48
|
247
|
100
|
|
|
|
934
|
if (my $easy = $self->SUPER::simple_convert($from, $to)) { |
49
|
211
|
|
|
|
|
597
|
return $easy; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# mb == megabyte |
53
|
36
|
100
|
|
|
|
133
|
if ($from =~ /^(.)b(yte(s?))?$/i) { |
54
|
3
|
50
|
|
|
|
22
|
if (my ($prefix) = $self->expand($1)) { |
55
|
3
|
|
|
|
|
23
|
return $self->simple_convert($prefix . "byte", $to); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
33
|
|
|
|
|
78
|
return; # Failed |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |