line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
26
|
|
|
26
|
|
158
|
use strict; |
|
26
|
|
|
|
|
53
|
|
|
26
|
|
|
|
|
838
|
|
2
|
26
|
|
|
26
|
|
119
|
use warnings; |
|
26
|
|
|
|
|
49
|
|
|
26
|
|
|
|
|
884
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: a tolerance "m +/- n" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package |
6
|
|
|
|
|
|
|
Number::Tolerant::Type::plus_or_minus; |
7
|
26
|
|
|
26
|
|
114
|
use parent qw(Number::Tolerant::Type); |
|
26
|
|
|
|
|
57
|
|
|
26
|
|
|
|
|
128
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
1
|
7
|
sub construct { shift; |
10
|
|
|
|
|
|
|
{ |
11
|
5
|
|
|
|
|
27
|
value => $_[0], |
12
|
|
|
|
|
|
|
variance => $_[1], |
13
|
|
|
|
|
|
|
min => $_[0] - $_[1], |
14
|
|
|
|
|
|
|
max => $_[0] + $_[1] |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub parse { |
19
|
22
|
|
|
22
|
1
|
54
|
my ($self, $string, $factory) = @_; |
20
|
|
|
|
|
|
|
|
21
|
22
|
|
|
|
|
115
|
my $number = $self->number_re; |
22
|
|
|
|
|
|
|
|
23
|
22
|
100
|
|
|
|
611
|
return $factory->new("$1", 'plus_or_minus', "$2") |
24
|
|
|
|
|
|
|
if $string =~ m!\A($number)\s*\+/-\s*($number)\z!; |
25
|
20
|
|
|
|
|
88
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
4
|
1
|
2273
|
sub stringify { "$_[0]->{value} +/- $_[0]->{variance}" } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub valid_args { |
31
|
103
|
|
|
103
|
1
|
425
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
103
|
100
|
|
|
|
168
|
return unless 3 == grep { defined } @_; |
|
233
|
|
|
|
|
551
|
|
34
|
31
|
100
|
|
|
|
106
|
return unless $_[1] eq 'plus_or_minus'; |
35
|
|
|
|
|
|
|
|
36
|
6
|
50
|
|
|
|
39
|
return unless defined (my $base = $self->normalize_number($_[0])); |
37
|
6
|
100
|
|
|
|
19
|
return unless defined (my $var = $self->normalize_number($_[2])); |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
19
|
return ($base, $var); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |