| 1 | package TUI::Objects::Rect; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: defines the class TRect | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 97 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 97 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 97 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 97 | ▶ | use List::Util qw( min max ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 97 | ▶ | use TUI::Objects::Point; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 97 | our $VERSION = '2.000002'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 97 | $VERSION =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 97 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 97 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 97 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | TRect | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | new_TRect | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 97 | ▶ | use Devel::StrictMode; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 97 | ▶ | use if STRICT => 'Hash::Util'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 97 | ▶ | use TUI::toolkit qw( :utils ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 97 | ▶ | use TUI::toolkit::Types qw( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | :is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | :types | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 97 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | sub TRect() { __PACKAGE__ } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | sub new_TRect { __PACKAGE__->from(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_TRect: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # public attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 97 | ▶ | our %HAS; BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | %HAS = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 44 | ▶ | a => sub { TPoint->new() }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 44 | ▶ | b => sub { TPoint->new() }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 97 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # This method accepts a variable number of arguments: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # If four arguments I<(ax, ay, bx, by)> are provided, it creates two L<TPoint|TUI::Objects::Point> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # objects for points I<a> and I<b> with the specified coordinates. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # If two arguments I<(a, b)> are provided, it sets points I<a> and I<b> to the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # provided L<TPoint|TUI::Objects::Point> objects. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # If no or any other number of arguments are provided, it initializes points | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # I<a> and I<b> with new L<TPoint|TUI::Objects::Point> objects with default values. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 50 | ▶ | sub new { # \$obj (%args) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 50 | my ( $class, $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 50 | ▶ | if ( @_ < 4 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 44 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | method => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | named => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 44 | ( $class ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | $self = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | a => $HAS{a}->(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 44 | b => $HAS{b}->(), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | elsif ( @_ < 8 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | method => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | named => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | a => HashLike, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | b => HashLike, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | ( $class, my $args ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | $self = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | a => TPoint->new( x => $args->{a}{x}, y => $args->{a}{y} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | b => TPoint->new( x => $args->{b}{x}, y => $args->{b}{y} ), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | method => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | named => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ax => Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ay => Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | bx => Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | by => Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | ( $class, my $args ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | $self = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | a => TPoint->new( x => $args->{ax}, y => $args->{ay} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | b => TPoint->new( x => $args->{bx}, y => $args->{by} ), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 50 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 50 | Hash::Util::lock_keys( %$self ) if STRICT; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 50 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } #/ sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | ▶ | sub from { # $obj ($ax, $ay, $bx, $by) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | method => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | pos => [Int, Int, Int, Int], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | my ( $class, @args ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | return $class->new( ax => $args[0], ay => $args[1], bx => $args[2], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | by => $args[3] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub assign { # void ($ax, $ay, $bx, $by) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | pos => [Int, Int, Int, Int], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my ( $self, $ax, $ay, $bx, $by ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $self->{a}{x} = $ax; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $self->{a}{y} = $ay; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $self->{b}{x} = $bx; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $self->{b}{y} = $by; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } #/ sub assign | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | sub clone { # $rect () | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | pos => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | my $class = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | return $class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | a => $self->{a}->clone(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | b => $self->{b}->clone(), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub dump { # $str () | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | pos => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | local $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return Data::Dumper::Dumper $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | ▶ | sub move { # void ($aDX, $aDY) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
move: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | pos => [Int, Int], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | my ( $self, $aDX, $aDY ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | $self->{a}{x} += $aDX; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | $self->{a}{y} += $aDY; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | $self->{b}{x} += $aDX; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | $self->{b}{y} += $aDY; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | sub grow { # void ($aDX, $aDY) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grow: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | pos => [Int, Int], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | my ( $self, $aDX, $aDY ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | $self->{a}{x} -= $aDX; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | $self->{a}{y} -= $aDY; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | $self->{b}{x} += $aDX; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | $self->{b}{y} += $aDY; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | ▶ | sub intersect { # void ($r) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
intersect: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | pos => [HashLike], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | my ( $self, $r ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | $self->{a}{x} = max( $self->{a}{x}, $r->{a}{x} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | $self->{a}{y} = max( $self->{a}{y}, $r->{a}{y} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | $self->{b}{x} = min( $self->{b}{x}, $r->{b}{x} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | $self->{b}{y} = min( $self->{b}{y}, $r->{b}{y} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | sub Union { # void ($r) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Union: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | pos => [HashLike], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | my ( $self, $r ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | $self->{a}{x} = min( $self->{a}{x}, $r->{a}{x} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | $self->{a}{y} = min( $self->{a}{y}, $r->{a}{y} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | $self->{b}{x} = max( $self->{b}{x}, $r->{b}{x} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | $self->{b}{y} = max( $self->{b}{y}, $r->{b}{y} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | sub contains { # $bool ($p) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contains: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | pos => [HashLike], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | my ( $self, $p ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | $p->{x} >= $self->{a}{x} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | && $p->{x} < $self->{b}{x} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | && $p->{y} >= $self->{a}{y} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | ▶ | && $p->{y} < $self->{b}{y}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%3/9
$p->{'x'} >= $self->{'a'}{'x'} && $p->{'x'} < $self->{'b'}{'x'} && $p->{'y'} >= $self->{'a'}{'y'} && $p->{'y'} < $self->{'b'}{'y'}
$p->{"x"} >= $self->{"a"}{"x"} and $p->{"x"} < $self->{"b"}{"x"} and $p->{"y"} >= $self->{"a"}{"y"}
$p->{"x"} >= $self->{"a"}{"x"} and $p->{"x"} < $self->{"b"}{"x"}
MC/DC0%0/4
$p->{'x'} >= $self->{'a'}{'x'} && $p->{'x'} < $self->{'b'}{'x'} && $p->{'y'} >= $self->{'a'}{'y'} && $p->{'y'} < $self->{'b'}{'y'}
$p->{"x"} >= $self->{"a"}{"x"}
$p->{"x"} < $self->{"b"}{"x"}
$p->{"y"} >= $self->{"a"}{"y"}
$p->{'y'} < $self->{'b'}{'y'}
Truth table20%1/5
A and B and C && D
A= $p->{"x"} >= $self->{"a"}{"x"}B= $p->{"x"} < $self->{"b"}{"x"}C= $p->{"y"} >= $self->{"a"}{"y"}D= $p->{'y'} < $self->{'b'}{'y'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | ▶ | sub equal { # $bool ($r, |$swap) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
equal: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | pos => [HashLike, HashLike, Bool, { optional => 1 }], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | my ( $one, $two, $swap ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | $one->{a}{x} == $two->{a}{x} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | && $one->{a}{y} == $two->{a}{y} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | && $one->{b}{x} == $two->{b}{x} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | ▶ | && $one->{b}{y} == $two->{b}{y}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%6/9
$one->{'a'}{'x'} == $two->{'a'}{'x'} && $one->{'a'}{'y'} == $two->{'a'}{'y'} && $one->{'b'}{'x'} == $two->{'b'}{'x'} && $one->{'b'}{'y'} == $two->{'b'}{'y'}
$one->{"a"}{"x"} == $two->{"a"}{"x"} and $one->{"a"}{"y"} == $two->{"a"}{"y"} and $one->{"b"}{"x"} == $two->{"b"}{"x"}
$one->{"a"}{"x"} == $two->{"a"}{"x"} and $one->{"a"}{"y"} == $two->{"a"}{"y"}
MC/DC25%1/4
$one->{'a'}{'x'} == $two->{'a'}{'x'} && $one->{'a'}{'y'} == $two->{'a'}{'y'} && $one->{'b'}{'x'} == $two->{'b'}{'x'} && $one->{'b'}{'y'} == $two->{'b'}{'y'}
$one->{"a"}{"x"} == $two->{"a"}{"x"}
$one->{"a"}{"y"} == $two->{"a"}{"y"}
$one->{"b"}{"x"} == $two->{"b"}{"x"}
$one->{'b'}{'y'} == $two->{'b'}{'y'}
Truth table40%2/5
A and B and C && D
A= $one->{"a"}{"x"} == $two->{"a"}{"x"}B= $one->{"a"}{"y"} == $two->{"a"}{"y"}C= $one->{"b"}{"x"} == $two->{"b"}{"x"}D= $one->{'b'}{'y'} == $two->{'b'}{'y'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | ▶ | sub not_equal { # $bool ($r, |$swap) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
not_equal: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | pos => [HashLike, HashLike, Bool, { optional => 1 }], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | my ( $one, $two, $swap ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | return !equal( $one, $two ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | sub isEmpty { # $bool () | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isEmpty: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | pos => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | return $self->{a}{x} >= $self->{b}{x} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | ▶ | || $self->{a}{y} >= $self->{b}{y}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'a'}{'x'} >= $self->{'b'}{'x'} || $self->{'a'}{'y'} >= $self->{'b'}{'y'}
MC/DC0%0/2
$self->{'a'}{'x'} >= $self->{'b'}{'x'} || $self->{'a'}{'y'} >= $self->{'b'}{'y'}
$self->{'a'}{'x'} >= $self->{'b'}{'x'}
$self->{'a'}{'y'} >= $self->{'b'}{'y'}
Truth table33%1/3
A || B
A= $self->{'a'}{'x'} >= $self->{'b'}{'x'}B= $self->{'a'}{'y'} >= $self->{'b'}{'y'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | use overload | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 97 | ▶ | '==' => \&equal, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | '!=' => \¬_equal, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 97 | fallback => 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 97 | ▶ | my $mk_accessors = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 97 | my ( $pkg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 97 | ▶ | assert ( @_ == 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 97 | ▶ | assert ( defined $pkg ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 97 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 97 | my %HAS = %{"${pkg}::HAS"}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 97 | for my $field ( keys %HAS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 194 | my $full_name = "${pkg}::$field"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 20 | ▶ | *$full_name = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 20 | ▶ | assert ( is_Object $_[0] ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 20 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | ▶ | assert ( is_Object $_[1] ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | $_[0]->{$field} = $_[1]->clone(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 20 | $_[0]->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 194 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } #/ for my $field ( keys %HAS) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 97 | }; #/ $mk_accessors = sub | |||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 97 | __PACKAGE__->$mk_accessors(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 97 | 1 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||