| 1 | package CXC::Number::Grid::Range; | ||||||||||||
| 2 | |||||||||||||
| 3 | # ABSTRACT: Helper class to track Ranges | ||||||||||||
| 4 | |||||||||||||
| 5 | 3 | ▶ | use v5.28; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 3 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 3 | ▶ | use experimental 'signatures'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 3 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | 3 | our $VERSION = '0.12'; | |||||||||||
| 13 | |||||||||||||
| 14 | use overload | ||||||||||||
| 15 | fallback => 0, | ||||||||||||
| 16 | 0 | ▶ | bool => sub { 1 }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 17 | 3 | '""' => \&to_string, | |||||||||||
| 18 | 3 | ▶ | '.' => \&concatenate; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | |||||||||||||
| 20 | |||||||||||||
| 21 | |||||||||||||
| 22 | |||||||||||||
| 23 | |||||||||||||
| 24 | |||||||||||||
| 25 | |||||||||||||
| 26 | 3 | has layer => ( is => 'ro' ); | |||||||||||
| 27 | |||||||||||||
| 28 | |||||||||||||
| 29 | |||||||||||||
| 30 | |||||||||||||
| 31 | |||||||||||||
| 32 | |||||||||||||
| 33 | |||||||||||||
| 34 | 3 | has include => ( is => 'ro' ); | |||||||||||
| 35 | |||||||||||||
| 36 | |||||||||||||
| 37 | |||||||||||||
| 38 | |||||||||||||
| 39 | |||||||||||||
| 40 | |||||||||||||
| 41 | |||||||||||||
| 42 | 3 | has lb => ( is => 'ro' ); | |||||||||||
| 43 | |||||||||||||
| 44 | |||||||||||||
| 45 | |||||||||||||
| 46 | |||||||||||||
| 47 | |||||||||||||
| 48 | |||||||||||||
| 49 | |||||||||||||
| 50 | 3 | has ub => ( is => 'ro' ); | |||||||||||
| 51 | |||||||||||||
| 52 | |||||||||||||
| 53 | |||||||||||||
| 54 | |||||||||||||
| 55 | |||||||||||||
| 56 | |||||||||||||
| 57 | ▶ | around BUILDARGS => sub ( $orig, $class, @args ) { | |||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||
| 58 | |||||||||||||
| 59 | 58 | ▶ | my %args = ref $args[0] ? $args[0]->%* : @args; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 60 | |||||||||||||
| 61 | @args{ 'layer', 'include' } = delete( $args{value} )->@* | ||||||||||||
| 62 | 58 | ▶ | if defined $args{value}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 63 | |||||||||||||
| 64 | 58 | return $class->$orig( \%args ); | |||||||||||
| 65 | 3 | }; | |||||||||||
| 66 | |||||||||||||
| 67 | |||||||||||||
| 68 | |||||||||||||
| 69 | |||||||||||||
| 70 | |||||||||||||
| 71 | |||||||||||||
| 72 | |||||||||||||
| 73 | |||||||||||||
| 74 | |||||||||||||
| 75 | |||||||||||||
| 76 | |||||||||||||
| 77 | |||||||||||||
| 78 | |||||||||||||
| 79 | |||||||||||||
| 80 | |||||||||||||
| 81 | 0 | ▶ | sub to_string ( $self, $ =, $ = ) { | ||||||||||
|
Subroutine
to_string: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||
| 82 | 0 | ▶ | my $ub = $self->ub // 'undef'; | ||||||||||
|
Condition0%0/2
$self->ub // "undef"
MC/DC0%0/1
$self->ub // "undef"
$self->ub
Truth table0%0/2
A
A= $self->ub
| |||||||||||||
| 83 | 0 | ▶ | my $lb = $self->lb // 'undef'; | ||||||||||
|
Condition0%0/2
$self->lb // "undef"
MC/DC0%0/1
$self->lb // "undef"
$self->lb
Truth table0%0/2
A
A= $self->lb
| |||||||||||||
| 84 | 0 | ▶ | my $layer = $self->layer // 'undef'; | ||||||||||
|
Condition0%0/2
$self->layer // "undef"
MC/DC0%0/1
$self->layer // "undef"
$self->layer
Truth table0%0/2
A
A= $self->layer
| |||||||||||||
| 85 | 0 | ▶ | my $include = $self->include // 'undef'; | ||||||||||
|
Condition0%0/2
$self->include // "undef"
MC/DC0%0/1
$self->include // "undef"
$self->include
Truth table0%0/2
A
A= $self->include
| |||||||||||||
| 86 | 0 | "( $lb, $ub ) => { layer => $layer, include => $include }"; | |||||||||||
| 87 | } | ||||||||||||
| 88 | |||||||||||||
| 89 | |||||||||||||
| 90 | |||||||||||||
| 91 | |||||||||||||
| 92 | |||||||||||||
| 93 | |||||||||||||
| 94 | |||||||||||||
| 95 | |||||||||||||
| 96 | |||||||||||||
| 97 | |||||||||||||
| 98 | |||||||||||||
| 99 | |||||||||||||
| 100 | |||||||||||||
| 101 | |||||||||||||
| 102 | |||||||||||||
| 103 | 0 | ▶ | sub concatenate ( $self, $other, $swap = 0 ) { | ||||||||||
|
Subroutine
concatenate: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 104 | 0 | my $str = $self->to_string; | |||||||||||
| 105 | 0 | ▶ | return $swap ? $other . $str : $str . $other; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 106 | } | ||||||||||||
| 107 | |||||||||||||
| 108 | |||||||||||||
| 109 | |||||||||||||
| 110 | |||||||||||||
| 111 | |||||||||||||
| 112 | |||||||||||||
| 113 | |||||||||||||
| 114 | |||||||||||||
| 115 | |||||||||||||
| 116 | |||||||||||||
| 117 | ▶ | sub value ( $self ) { | |||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 118 | 2 | return [ $self->layer, $self->include ]; | |||||||||||
| 119 | } | ||||||||||||
| 120 | |||||||||||||
| 121 | 3 | 1; | |||||||||||
| 122 | |||||||||||||
| 123 | # | ||||||||||||
| 124 | # This file is part of CXC-Number | ||||||||||||
| 125 | # | ||||||||||||
| 126 | # This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory. | ||||||||||||
| 127 | # | ||||||||||||
| 128 | # This is free software, licensed under: | ||||||||||||
| 129 | # | ||||||||||||
| 130 | # The GNU General Public License, Version 3, June 2007 | ||||||||||||
| 131 | # | ||||||||||||
| 132 | |||||||||||||
| 133 | __END__ | ||||||||||||
| 134 | |||||||||||||
| 135 | =pod | ||||||||||||
| 136 | |||||||||||||
| 137 | =for :stopwords Diab Jerius Smithsonian Astrophysical Observatory ub | ||||||||||||
| 138 | |||||||||||||
| 139 | =head1 NAME | ||||||||||||
| 140 | |||||||||||||
| 141 | CXC::Number::Grid::Range - Helper class to track Ranges | ||||||||||||
| 142 | |||||||||||||
| 143 | =head1 VERSION | ||||||||||||
| 144 | |||||||||||||
| 145 | version 0.12 | ||||||||||||
| 146 | |||||||||||||
| 147 | =head1 DESCRIPTION | ||||||||||||
| 148 | |||||||||||||
| 149 | A utility class to manage Ranges when doing bin manipulations with trees. | ||||||||||||
| 150 | |||||||||||||
| 151 | =head1 OBJECT ATTRIBUTES | ||||||||||||
| 152 | |||||||||||||
| 153 | =head2 layer | ||||||||||||
| 154 | |||||||||||||
| 155 | The grid layer id | ||||||||||||
| 156 | |||||||||||||
| 157 | =head2 include | ||||||||||||
| 158 | |||||||||||||
| 159 | Whether this range is included or excluded. | ||||||||||||
| 160 | |||||||||||||
| 161 | =head2 lb | ||||||||||||
| 162 | |||||||||||||
| 163 | The inclusive range lower bound | ||||||||||||
| 164 | |||||||||||||
| 165 | =head2 ub | ||||||||||||
| 166 | |||||||||||||
| 167 | The exclusive range upper bound | ||||||||||||
| 168 | |||||||||||||
| 169 | =head1 METHODS | ||||||||||||
| 170 | |||||||||||||
| 171 | =head2 to_string | ||||||||||||
| 172 | |||||||||||||
| 173 | $string = $self->to_string | ||||||||||||
| 174 | |||||||||||||
| 175 | Return a string representation of the range. | ||||||||||||
| 176 | |||||||||||||
| 177 | =head2 concatenate | ||||||||||||
| 178 | |||||||||||||
| 179 | $string = $range->concatenate( $thing, $swap=false ) | ||||||||||||
| 180 | |||||||||||||
| 181 | Concatenate the stringified version of $range with $thing. | ||||||||||||
| 182 | |||||||||||||
| 183 | Set C<$swap> to true if the order should be reversed. | ||||||||||||
| 184 | |||||||||||||
| 185 | =head2 value | ||||||||||||
| 186 | |||||||||||||
| 187 | [ $layer, $include ] = $range->value; | ||||||||||||
| 188 | |||||||||||||
| 189 | Return an arrayref containing the layer id and the include value for | ||||||||||||
| 190 | the range. | ||||||||||||
| 191 | |||||||||||||
| 192 | =head1 OVERLOAD | ||||||||||||
| 193 | |||||||||||||
| 194 | =head2 "" | ||||||||||||
| 195 | |||||||||||||
| 196 | Stringification is overloaded via the L</to_string> method. | ||||||||||||
| 197 | |||||||||||||
| 198 | =head2 . | ||||||||||||
| 199 | |||||||||||||
| 200 | Concatenation is overloaded via the L</concatenate> method. | ||||||||||||
| 201 | |||||||||||||
| 202 | =head1 INTERNALS | ||||||||||||
| 203 | |||||||||||||
| 204 | =for Pod::Coverage BUILDARGS | ||||||||||||
| 205 | |||||||||||||
| 206 | =head1 SUPPORT | ||||||||||||
| 207 | |||||||||||||
| 208 | =head2 Bugs | ||||||||||||
| 209 | |||||||||||||
| 210 | Please report any bugs or feature requests to bug-cxc-number@rt.cpan.org or through the web interface at: L<https://rt.cpan.org/Public/Dist/Display.html?Name=CXC-Number> | ||||||||||||
| 211 | |||||||||||||
| 212 | =head2 Source | ||||||||||||
| 213 | |||||||||||||
| 214 | Source is available at | ||||||||||||
| 215 | |||||||||||||
| 216 | https://gitlab.com/djerius/cxc-number | ||||||||||||
| 217 | |||||||||||||
| 218 | and may be cloned from | ||||||||||||
| 219 | |||||||||||||
| 220 | https://gitlab.com/djerius/cxc-number.git | ||||||||||||
| 221 | |||||||||||||
| 222 | =head1 SEE ALSO | ||||||||||||
| 223 | |||||||||||||
| 224 | Please see those modules/websites for more information related to this module. | ||||||||||||
| 225 | |||||||||||||
| 226 | =over 4 | ||||||||||||
| 227 | |||||||||||||
| 228 | =item * | ||||||||||||
| 229 | |||||||||||||
| 230 | L<CXC::Number|CXC::Number> | ||||||||||||
| 231 | |||||||||||||
| 232 | =back | ||||||||||||
| 233 | |||||||||||||
| 234 | =head1 AUTHOR | ||||||||||||
| 235 | |||||||||||||
| 236 | Diab Jerius <djerius@cpan.org> | ||||||||||||
| 237 | |||||||||||||
| 238 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 239 | |||||||||||||
| 240 | This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory. | ||||||||||||
| 241 | |||||||||||||
| 242 | This is free software, licensed under: | ||||||||||||
| 243 | |||||||||||||
| 244 | The GNU General Public License, Version 3, June 2007 | ||||||||||||
| 245 | |||||||||||||
| 246 | =cut | ||||||||||||