line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ODS::Table::Column::Float; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use YAOO; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'ODS::Table::Column::Base'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
333
|
use ODS::Utils qw/error/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has precision => isa(integer); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has number => isa(boolean); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub validation { |
14
|
0
|
0
|
0
|
0
|
0
|
|
if (ref($_[1]) || ${$_[1]} !~ m/\d+(\.\d+)?/) { |
|
0
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
croak sprintf "The value passed to the %s column does not match the float constraint.", |
16
|
|
|
|
|
|
|
$_[0]->name; |
17
|
|
|
|
|
|
|
} |
18
|
0
|
|
|
|
|
|
return $_[1]; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub inflation { |
22
|
0
|
|
|
0
|
0
|
|
my ($self, $value) = @_; |
23
|
0
|
0
|
|
|
|
|
if ($self->precision) { |
24
|
0
|
|
|
|
|
|
my $precision = '%.' . $self->precision . 'f'; |
25
|
0
|
|
|
|
|
|
$value = sprintf($precision, $value); |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
|
return $value; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub deflation { |
31
|
0
|
|
|
0
|
0
|
|
my ($self, $value) = @_; |
32
|
0
|
0
|
0
|
|
|
|
if ($_[0]->number && $_[0]->precision) { |
33
|
0
|
|
|
|
|
|
$value = 0 + $value; |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
return $value; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |