line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Integer Object for Perl 5 |
2
|
|
|
|
|
|
|
package Data::Object::Integer; |
3
|
|
|
|
|
|
|
|
4
|
15
|
|
|
15
|
|
1057
|
use 5.010; |
|
15
|
|
|
|
|
75
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
75
|
use Scalar::Util 'blessed', 'looks_like_number'; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
1082
|
|
7
|
15
|
|
|
15
|
|
568
|
use Data::Object 'deduce_deep', 'detract_deep', 'throw'; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
744
|
|
8
|
15
|
|
|
15
|
|
521
|
use Data::Object::Class 'with'; |
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
115
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Data::Object::Role::Integer'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use overload ( |
13
|
15
|
|
|
|
|
128
|
'bool' => 'data', |
14
|
|
|
|
|
|
|
'""' => 'data', |
15
|
|
|
|
|
|
|
'~~' => 'data', |
16
|
|
|
|
|
|
|
fallback => 1, |
17
|
15
|
|
|
15
|
|
5941
|
); |
|
15
|
|
|
|
|
36
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.42'; # VERSION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
37
|
|
|
37
|
0
|
2008
|
my $class = shift; |
23
|
37
|
|
|
|
|
75
|
my $args = shift; |
24
|
37
|
|
|
|
|
56
|
my $role = 'Data::Object::Role::Type'; |
25
|
|
|
|
|
|
|
|
26
|
37
|
0
|
33
|
|
|
190
|
$args = $args->data if blessed($args) |
|
|
|
33
|
|
|
|
|
27
|
|
|
|
|
|
|
and $args->can('does') |
28
|
|
|
|
|
|
|
and $args->does($role); |
29
|
|
|
|
|
|
|
|
30
|
37
|
|
|
|
|
81
|
$args =~ s/^\+//; # not keen on this but ... |
31
|
|
|
|
|
|
|
|
32
|
37
|
50
|
33
|
|
|
320
|
throw 'Type Instantiation Error: Not an Integer' |
|
|
|
33
|
|
|
|
|
33
|
|
|
|
|
|
|
unless defined($args) && !ref($args) |
34
|
|
|
|
|
|
|
&& looks_like_number($args); |
35
|
|
|
|
|
|
|
|
36
|
37
|
|
|
|
|
195
|
return bless \$args, $class; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub data { |
40
|
22
|
|
|
22
|
0
|
8444
|
goto &detract; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub detract { |
44
|
22
|
|
|
22
|
0
|
73
|
return detract_deep shift; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
around 'downto' => sub { |
48
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
49
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
50
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
around 'eq' => sub { |
54
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
55
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
56
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
around 'gt' => sub { |
60
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
61
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
62
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
around 'gte' => sub { |
66
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
67
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
68
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
around 'lt' => sub { |
72
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
73
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
74
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
75
|
|
|
|
|
|
|
}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
around 'lte' => sub { |
78
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
79
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
80
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
around 'ne' => sub { |
84
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
85
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
86
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
around 'to' => sub { |
90
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
91
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
92
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
around 'upto' => sub { |
96
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
97
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
98
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
99
|
|
|
|
|
|
|
}; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |