| 1 | 25 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 25 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | # ABSTRACT: a tolerance "m (-l or +n)" | ||||||||||
| 4 | |||||||||||
| 5 | package | ||||||||||
| 6 | Number::Tolerant::Type::offset; | ||||||||||
| 7 | 25 | ▶ | use parent qw(Number::Tolerant::Type); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | sub construct { shift; | ||||||||
|
Subroutine
construct: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 10 | { | ||||||||||
| 11 | 2 | value => $_[0], | |||||||||
| 12 | min => $_[0] + $_[1], | ||||||||||
| 13 | max => $_[0] + $_[2] | ||||||||||
| 14 | } | ||||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 27 | ▶ | sub parse { | ||||||||
|
Subroutine
parse: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 18 | 27 | my ($self, $string, $factory) = @_; | |||||||||
| 19 | |||||||||||
| 20 | 27 | my $number = $self->number_re; | |||||||||
| 21 | 27 | ▶ | return $factory->new("$1", 'offset', "$2", "$3") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | if $string =~ m!\A($number)\s+\(?\s*($number)\s+($number)\s*\)?\s*\z!; | ||||||||||
| 23 | |||||||||||
| 24 | 26 | return; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 2 | ▶ | sub stringify { | ||||||||
|
Subroutine
stringify: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 28 | 2 | my ($self) = @_; | |||||||||
| 29 | return sprintf "%s (-%s +%s)", | ||||||||||
| 30 | $_[0]->{value}, | ||||||||||
| 31 | ($_[0]->{value} - $_[0]->{min}), | ||||||||||
| 32 | 2 | ($_[0]->{max} - $_[0]->{value}); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 110 | ▶ | sub valid_args { | ||||||||
|
Subroutine
valid_args: called CC=8 SCAR=21.2
Pod
documented
| |||||||||||
| 36 | 110 | my $self = shift; | |||||||||
| 37 | |||||||||||
| 38 | 110 | ▶ | return if @_ > 4; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | |||||||||||
| 40 | 110 | ▶ | return unless defined(my $lhs_number = $self->normalize_number($_[0])); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 87 | ▶ | return unless defined(my $minus_number = $self->normalize_number($_[2])); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 31 | ▶ | return unless defined(my $plus_number = $self->normalize_number($_[3])); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | |||||||||||
| 44 | 2 | ▶ | return unless $_[1] eq 'offset'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 2 | ▶ | return unless $minus_number <= 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 2 | ▶ | return unless $plus_number >= 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | |||||||||||
| 48 | 2 | return ($lhs_number, $minus_number, $plus_number) | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 25 | 1; | |||||||||
| 52 | |||||||||||
| 53 | __END__ | ||||||||||