| 1 | package Schedule::Easing::Ease; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use Carp qw/carp confess/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Scalar::Util qw/looks_like_number/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Schedule::Easing::Function; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | our $VERSION='0.1.5'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 70 | ▶ | sub _default_keys { return qw/name match begin final tsA tsB shape shapeopt _warnExpired/ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_keys: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 70 | ▶ | sub _default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 70 | name =>undef, | |||||||||||||||||||||||||||||||||||||||||
| 16 | match=>qr/./, | ||||||||||||||||||||||||||||||||||||||||||
| 17 | begin=>0, | ||||||||||||||||||||||||||||||||||||||||||
| 18 | final=>1, | ||||||||||||||||||||||||||||||||||||||||||
| 19 | tsA =>0, | ||||||||||||||||||||||||||||||||||||||||||
| 20 | tsB =>1, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | shape=>'linear', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | shapeopt=>[], | ||||||||||||||||||||||||||||||||||||||||||
| 23 | _warnExpired=>0, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 19 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 19 | my ($ref,%opt)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 19 | ▶ | my $class=ref($ref)||$ref; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $ref || $ref
MC/DC0%0/2
ref $ref || $ref
ref $ref
$ref
Truth table66%2/3
A || B
A= ref $refB= $ref
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | my %self=( | ||||||||||||||||||||||||||||||||||||||||||
| 31 | $class->_default(), | ||||||||||||||||||||||||||||||||||||||||||
| 32 | (ref($ref)?%$ref:()), | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 19 | ▶ | map {$_=>$opt{$_}} grep {defined($opt{$_})} $class->_default_keys() | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 19 | return bless(\%self,$class)->validate()->init(); | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 70 | ▶ | sub validate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate: called CC=14 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 70 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 70 | foreach my $k (qw/tsA tsB begin final/) { | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if(!defined($$self{$k})) { confess("Must be defined: $k") } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 268 | ▶ | if(!looks_like_number($$self{$k})) { confess("Must be numeric: $k") } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 62 | ▶ | if(ref($$self{match}) ne 'Regexp') { confess('Must be Regexp: match') } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if(ref($$self{name})) { confess('Must be string: name') } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 59 | foreach my $k (qw/begin final/) { | |||||||||||||||||||||||||||||||||||||||||
| 47 | 118 | ▶ | if($$self{$k}<0) { $$self{$k}=0; carp("$k<0"); $$self{_err}=1 } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 118 | ▶ | if($$self{$k}>1) { $$self{$k}=1; carp("$k>1"); $$self{_err}=1 } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 59 | ▶ | if($$self{tsA}>=$$self{tsB}) { $$self{tsB}=1+$$self{tsA}; carp('tsA>=tsB'); $$self{_err}=1 } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 59 | ▶ | if($$self{_warnExpired}&&($$self{tsB}<time())&&(abs(0.5-$$self{final})>=0.5)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->{"_warnExpired"} and $self->{"tsB"} < time and abs "0.5" - $self->{"final"} >= "0.5"
$self->{"_warnExpired"} and $self->{"tsB"} < time
MC/DC66%2/3
$self->{"_warnExpired"} and $self->{"tsB"} < time and abs "0.5" - $self->{"final"} >= "0.5"
$self->{"_warnExpired"}
$self->{"tsB"} < time
abs "0.5" - $self->{"final"} >= "0.5"
Truth table75%3/4
A and B and C
A= $self->{"_warnExpired"}B= $self->{"tsB"} < timeC= abs "0.5" - $self->{"final"} >= "0.5"
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | ▶ | if($$self{name}) { carp("Event has expired: $$self{name}"); $$self{_err}=1 } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | else { carp("Event with tsB=$$self{tsB} has expired"); $$self{_err}=1 } | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 59 | $$self{_shaper} =Schedule::Easing::Function::shape($$self{shape}); | |||||||||||||||||||||||||||||||||||||||||
| 56 | 59 | $$self{_unshaper}=Schedule::Easing::Function::inverse($$self{shape}); | |||||||||||||||||||||||||||||||||||||||||
| 57 | 59 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 55 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 55 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 55 | $$self{tsrange}=int($$self{tsB}-$$self{tsA}); | |||||||||||||||||||||||||||||||||||||||||
| 63 | 55 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub includes { die 'Abstract' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
includes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub schedule { die 'Abstract' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
schedule: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 250087 | ▶ | sub matches { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
matches: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 250087 | my ($self,$message)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 250087 | ▶ | if($message=~$$self{match}) { return (matched=>1,%+) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 61 | return; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||