line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
26
|
|
|
26
|
|
129
|
use strict; |
|
26
|
|
|
|
|
51
|
|
|
26
|
|
|
|
|
823
|
|
2
|
26
|
|
|
26
|
|
129
|
use warnings; |
|
26
|
|
|
|
|
50
|
|
|
26
|
|
|
|
|
892
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: a tolerance "m (-l or +n)" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package |
6
|
|
|
|
|
|
|
Number::Tolerant::Type::offset; |
7
|
26
|
|
|
26
|
|
123
|
use parent qw(Number::Tolerant::Type); |
|
26
|
|
|
|
|
46
|
|
|
26
|
|
|
|
|
138
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
1
|
6
|
sub construct { shift; |
10
|
|
|
|
|
|
|
{ |
11
|
3
|
|
|
|
|
16
|
value => $_[0], |
12
|
|
|
|
|
|
|
min => $_[0] + $_[1], |
13
|
|
|
|
|
|
|
max => $_[0] + $_[2] |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub parse { |
18
|
17
|
|
|
17
|
1
|
40
|
my ($self, $string, $factory) = @_; |
19
|
|
|
|
|
|
|
|
20
|
17
|
|
|
|
|
116
|
my $number = $self->number_re; |
21
|
17
|
100
|
|
|
|
921
|
return $factory->new("$1", 'offset', "$2", "$3") |
22
|
|
|
|
|
|
|
if $string =~ m!\A($number)\s+\(?\s*($number)\s+($number)\s*\)?\s*\z!; |
23
|
|
|
|
|
|
|
|
24
|
16
|
|
|
|
|
114
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub stringify { |
28
|
7
|
|
|
7
|
1
|
2373
|
my ($self) = @_; |
29
|
|
|
|
|
|
|
return sprintf "%s (-%s +%s)", |
30
|
|
|
|
|
|
|
$_[0]->{value}, |
31
|
|
|
|
|
|
|
($_[0]->{value} - $_[0]->{min}), |
32
|
7
|
|
|
|
|
84
|
($_[0]->{max} - $_[0]->{value}); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub valid_args { |
36
|
72
|
|
|
72
|
1
|
117
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
72
|
50
|
|
|
|
229
|
return if @_ > 4; |
39
|
|
|
|
|
|
|
|
40
|
72
|
100
|
|
|
|
332
|
return unless defined(my $lhs_number = $self->normalize_number($_[0])); |
41
|
55
|
100
|
|
|
|
388
|
return unless defined(my $minus_number = $self->normalize_number($_[2])); |
42
|
24
|
100
|
|
|
|
405
|
return unless defined(my $plus_number = $self->normalize_number($_[3])); |
43
|
|
|
|
|
|
|
|
44
|
3
|
50
|
|
|
|
12
|
return unless $_[1] eq 'offset'; |
45
|
3
|
50
|
|
|
|
12
|
return unless $minus_number <= 0; |
46
|
3
|
50
|
|
|
|
9
|
return unless $plus_number >= 0; |
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
|
|
47
|
return ($lhs_number, $minus_number, $plus_number) |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |