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