line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: A Float Object for Perl 5 |
2
|
|
|
|
|
|
|
package Data::Object::Float; |
3
|
|
|
|
|
|
|
|
4
|
26
|
|
|
26
|
|
13159
|
use 5.010; |
|
26
|
|
|
|
|
100
|
|
|
26
|
|
|
|
|
1135
|
|
5
|
|
|
|
|
|
|
|
6
|
26
|
|
|
26
|
|
135
|
use Carp 'confess'; |
|
26
|
|
|
|
|
39
|
|
|
26
|
|
|
|
|
1962
|
|
7
|
26
|
|
|
26
|
|
151
|
use Scalar::Util 'blessed', 'looks_like_number'; |
|
26
|
|
|
|
|
38
|
|
|
26
|
|
|
|
|
1577
|
|
8
|
26
|
|
|
26
|
|
6158
|
use Data::Object 'deduce_deep', 'detract_deep'; |
|
26
|
|
|
|
|
56
|
|
|
26
|
|
|
|
|
10320
|
|
9
|
26
|
|
|
26
|
|
6048
|
use Data::Object::Class 'with'; |
|
26
|
|
|
|
|
517
|
|
|
26
|
|
|
|
|
278
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Data::Object::Role::Float'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use overload ( |
14
|
26
|
|
|
|
|
232
|
'bool' => 'data', |
15
|
|
|
|
|
|
|
'""' => 'data', |
16
|
|
|
|
|
|
|
'~~' => 'data', |
17
|
|
|
|
|
|
|
fallback => 1, |
18
|
26
|
|
|
26
|
|
34692
|
); |
|
26
|
|
|
|
|
48
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.20'; # VERSION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
34
|
|
|
34
|
0
|
29959
|
my $class = shift; |
24
|
34
|
|
|
|
|
69
|
my $data = shift; |
25
|
|
|
|
|
|
|
|
26
|
34
|
|
|
|
|
272
|
$data =~ s/^\+//; # not keen on this but ... |
27
|
|
|
|
|
|
|
|
28
|
34
|
|
33
|
|
|
211
|
$class = ref($class) || $class; |
29
|
34
|
50
|
33
|
|
|
288
|
unless (blessed($data) && $data->isa($class)) { |
30
|
34
|
50
|
33
|
|
|
350
|
confess 'Type Instantiation Error: Not a Float or Number' |
|
|
|
33
|
|
|
|
|
31
|
|
|
|
|
|
|
unless defined($data) && !ref($data) |
32
|
|
|
|
|
|
|
&& looks_like_number($data); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
34
|
|
|
|
|
172
|
return bless \$data, $class; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub data { |
39
|
43
|
|
|
43
|
0
|
6158
|
goto &detract; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub detract { |
43
|
44
|
|
|
44
|
0
|
165
|
return detract_deep shift; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
around 'downto' => sub { |
47
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
48
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
49
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
around 'eq' => sub { |
53
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
54
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
55
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
around 'gt' => sub { |
59
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
60
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
61
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
around 'gte' => sub { |
65
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
66
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
67
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
around 'lt' => sub { |
71
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
72
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
73
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
74
|
|
|
|
|
|
|
}; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
around 'lte' => sub { |
77
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
78
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
79
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
around 'ne' => sub { |
83
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
84
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
85
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
around 'to' => sub { |
89
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
90
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
91
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
92
|
|
|
|
|
|
|
}; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
around 'upto' => sub { |
95
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
96
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
97
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
98
|
|
|
|
|
|
|
}; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |