| 1 | package Chart::Clicker::Data::Range; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 16 | $Chart::Clicker::Data::Range::VERSION = '2.90'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use constant EPSILON => 0.0001; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | # ABSTRACT: A range of Data | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | subtype 'Lower' | ||||||||||||||||||||||||||||||||||||||||||
| 12 | => as 'Num|Undef' | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 58 | ▶ | => where { defined($_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | coerce 'Lower' | ||||||||||||||||||||||||||||||||||||||||||
| 16 | => from 'Undef' | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | => via { - EPSILON }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 16 | has 'lower' => ( is => 'rw', isa => 'Lower', coerce => 1); | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 16 | has 'max' => ( is => 'rw', isa => 'Num' ); | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 16 | has 'min' => ( is => 'rw', isa => 'Num' ); | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | subtype 'Upper' | ||||||||||||||||||||||||||||||||||||||||||
| 29 | => as 'Num|Undef' | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 58 | ▶ | => where { defined($_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | coerce 'Upper' | ||||||||||||||||||||||||||||||||||||||||||
| 33 | => from 'Num|Undef' | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | => via { EPSILON }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 16 | has 'upper' => ( is => 'rw', isa => 'Upper', coerce => 1); | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 16 | has 'ticks' => ( is => 'rw', isa => 'Int', default => 5 ); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 113 | ▶ | after 'lower' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 113 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 113 | ▶ | if(defined($self->{'min'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 3 | $self->{'lower'} = $self->{'min'}; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 113 | ▶ | $self->{'lower'} = $self->{'min'} unless (defined($self->{'lower'})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 113 | ▶ | $self->{'upper'} = $self->{'max'} unless (defined($self->{'upper'})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 113 | ▶ | if(defined($self->{'lower'}) && defined($self->{'upper'}) && $self->{'lower'} == $self->{'upper'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $self->{"lower"} and defined $self->{"upper"} and $self->{"lower"} == $self->{"upper"}
defined $self->{"lower"} and defined $self->{"upper"}
MC/DC0%0/3
defined $self->{"lower"} and defined $self->{"upper"} and $self->{"lower"} == $self->{"upper"}
defined $self->{"lower"}
defined $self->{"upper"}
$self->{"lower"} == $self->{"upper"}
Truth table75%3/4
A and B and C
A= defined $self->{"lower"}B= defined $self->{"upper"}C= $self->{"lower"} == $self->{"upper"}
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $self->{'lower'} = $self->{'lower'} - EPSILON; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $self->{'lower'} = $self->{'lower'} + EPSILON; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 16 | }; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 146 | ▶ | after 'upper' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 146 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 146 | ▶ | if(defined($self->{'max'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | $self->{'upper'} = $self->{'max'}; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 146 | ▶ | $self->{'lower'} = $self->{'min'} unless (defined($self->{'lower'})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 146 | ▶ | $self->{'upper'} = $self->{'max'} unless (defined($self->{'upper'})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 146 | ▶ | if(defined($self->{'lower'}) && defined($self->{'upper'}) && $self->{'lower'} == $self->{'upper'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $self->{"lower"} and defined $self->{"upper"} and $self->{"lower"} == $self->{"upper"}
defined $self->{"lower"} and defined $self->{"upper"}
MC/DC0%0/3
defined $self->{"lower"} and defined $self->{"upper"} and $self->{"lower"} == $self->{"upper"}
defined $self->{"lower"}
defined $self->{"upper"}
$self->{"lower"} == $self->{"upper"}
Truth table50%2/4
A and B and C
A= defined $self->{"lower"}B= defined $self->{"upper"}C= $self->{"lower"} == $self->{"upper"}
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->{'upper'} = $self->{'upper'} - EPSILON; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $self->{'upper'} = $self->{'upper'} + EPSILON; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 16 | }; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 9 | ▶ | after 'min' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 9 | ▶ | if(defined($self->{'min'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | $self->{'lower'} = $self->{'min'}; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 16 | }; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 9 | ▶ | after 'max' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 9 | ▶ | if(defined($self->{'max'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | $self->{'upper'} = $self->{'max'}; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 16 | }; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub add { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my ($self, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if(defined($self->upper)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $self->upper($self->upper + $range->upper); | |||||||||||||||||||||||||||||||||||||||||
| 99 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $self->upper($range->upper); | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if(!defined($self->lower) || ($range->lower < $self->lower)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $self->lower or $range->lower < $self->lower
MC/DC0%0/2
not defined $self->lower or $range->lower < $self->lower
not defined $self->lower
$range->lower < $self->lower
Truth table0%0/3
not(A) or B
A= not defined $self->lowerB= $range->lower < $self->lower
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $self->lower($range->lower); | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 8 | ▶ | sub combine { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
combine: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 8 | my ($self, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 8 | ▶ | unless(defined($self->min)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 7 | ▶ | if(!defined($self->lower) || ($range->lower < $self->lower)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $self->lower or $range->lower < $self->lower
MC/DC100%2/2
not defined $self->lower or $range->lower < $self->lower
not defined $self->lower
$range->lower < $self->lower
Truth table100%3/3
not(A) or B
A= not defined $self->lowerB= $range->lower < $self->lower
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 5 | $self->lower($range->lower); | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 8 | ▶ | unless(defined($self->max)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 7 | ▶ | if(!defined($self->upper) || ($range->upper > $self->upper)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $self->upper or $range->upper > $self->upper
MC/DC100%2/2
not defined $self->upper or $range->upper > $self->upper
not defined $self->upper
$range->upper > $self->upper
Truth table100%3/3
not(A) or B
A= not defined $self->upperB= $range->upper > $self->upper
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 6 | $self->upper($range->upper); | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 8 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 | ▶ | sub contains { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contains: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | ▶ | return 1 if $value >= $self->lower && $value <= $self->upper; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$value >= $self->lower and $value <= $self->upper
MC/DC50%1/2
$value >= $self->lower and $value <= $self->upper
$value >= $self->lower
$value <= $self->upper
Truth table66%2/3
A and B
A= $value >= $self->lowerB= $value <= $self->upper
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 52 | ▶ | sub span { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
span: called CC=2 SCAR=8.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 52 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 52 | my $span = $self->upper - $self->lower; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | #we still want to be able to see flat lines! | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 52 | ▶ | if ($span <= EPSILON) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $self->upper($self->upper() + EPSILON); | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $self->lower($self->lower() - EPSILON); | |||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $span = $self->upper - $self->lower; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 52 | return $span; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 16 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 16 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | __END__ | ||||||||||||||||||||||||||||||||||||||||||