| 1 | 8 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 8 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | package Math::Shape::Range; | ||||||||||
| 4 | 8 | $Math::Shape::Range::VERSION = '0.15'; | |||||||||
| 5 | 8 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 8 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 8 | ▶ | use Math::Shape::Utils; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 8 | ▶ | use List::Util qw/min max/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | # ABSTRACT: a range object which has min and max values | ||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | sub new | ||||||||||
| 14 | 182 | ▶ | { | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 15 | 182 | ▶ | croak 'incorrect number of args' unless @_ == 3; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 182 | my ($class, $min, $max) = @_; | |||||||||
| 17 | 182 | bless { min => $min, max => $max }, $class; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | sub sort | ||||||||||
| 22 | 94 | ▶ | { | ||||||||
|
Subroutine
sort: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 23 | 94 | my $self = shift; | |||||||||
| 24 | |||||||||||
| 25 | 94 | ▶ | if ($self->{min} > $self->{max}) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | { | ||||||||||
| 27 | Math::Shape::Range->new( | ||||||||||
| 28 | $self->{max}, | ||||||||||
| 29 | $self->{min}, | ||||||||||
| 30 | 47 | ); | |||||||||
| 31 | } | ||||||||||
| 32 | else { | ||||||||||
| 33 | 47 | $self; | |||||||||
| 34 | } | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | sub is_overlapping | ||||||||||
| 39 | 42 | ▶ | { | ||||||||
|
Subroutine
is_overlapping: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||
| 40 | 42 | ▶ | croak 'Must provide another Math::Shape::Range object as argument' unless $_[1]->isa('Math::Shape::Range'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 42 | overlap($_[0]->{min}, $_[0]->{max}, $_[1]->{min}, $_[1]->{max}); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | sub hull | ||||||||||
| 46 | 26 | ▶ | { | ||||||||
|
Subroutine
hull: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 47 | 26 | ▶ | croak 'Must provide another Math::Shape::Range object as argument' unless $_[1]->isa('Math::Shape::Range'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 26 | my ($self, $other_range) = @_; | |||||||||
| 49 | |||||||||||
| 50 | 26 | my $min = min $self->{min}, $other_range->{min}; | |||||||||
| 51 | 26 | my $max = max $self->{max}, $other_range->{max}; | |||||||||
| 52 | |||||||||||
| 53 | 26 | Math::Shape::Range->new($min, $max); | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | 8 | 1; | |||||||||
| 58 | |||||||||||
| 59 | __END__ | ||||||||||