line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
26
|
|
|
26
|
|
149
|
use strict; |
|
26
|
|
|
|
|
45
|
|
|
26
|
|
|
|
|
856
|
|
2
|
26
|
|
|
26
|
|
131
|
use warnings; |
|
26
|
|
|
|
|
69
|
|
|
26
|
|
|
|
|
804
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: a tolerance "m +/- n%" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package |
6
|
|
|
|
|
|
|
Number::Tolerant::Type::plus_or_minus_pct; |
7
|
26
|
|
|
26
|
|
126
|
use parent qw(Number::Tolerant::Type); |
|
26
|
|
|
|
|
54
|
|
|
26
|
|
|
|
|
107
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
1
|
9
|
sub construct { shift; |
10
|
|
|
|
|
|
|
{ |
11
|
5
|
|
|
|
|
32
|
value => $_[0], |
12
|
|
|
|
|
|
|
variance => $_[1], |
13
|
|
|
|
|
|
|
min => $_[0] - $_[0]*($_[1]/100), |
14
|
|
|
|
|
|
|
max => $_[0] + $_[0]*($_[1]/100) |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub parse { |
19
|
26
|
|
|
26
|
1
|
58
|
my ($self, $string, $factory) = @_; |
20
|
26
|
|
|
|
|
107
|
my $number = $self->number_re; |
21
|
|
|
|
|
|
|
|
22
|
26
|
100
|
|
|
|
608
|
return $factory->new("$1", 'plus_or_minus_pct', "$2") |
23
|
|
|
|
|
|
|
if $string =~ m!\A($number)\s*\+/-\s*($number)%\z!; |
24
|
25
|
|
|
|
|
96
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
9
|
|
|
9
|
1
|
4780
|
sub stringify { "$_[0]->{value} +/- $_[0]->{variance}%" } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub valid_args { |
30
|
102
|
|
|
102
|
1
|
157
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
102
|
100
|
|
|
|
179
|
return unless 3 == grep { defined } @_; |
|
222
|
|
|
|
|
526
|
|
33
|
26
|
100
|
|
|
|
112
|
return unless $_[1] eq 'plus_or_minus_pct'; |
34
|
|
|
|
|
|
|
|
35
|
6
|
50
|
|
|
|
33
|
return unless defined (my $base = $self->normalize_number($_[0])); |
36
|
6
|
100
|
|
|
|
18
|
return unless defined (my $var = $self->normalize_number($_[2])); |
37
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
1695
|
return ($base, $var); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |