| 1 | package Geometry::Primitive::Dimension; | ||||||||||||||||||||
| 2 | 1 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use MooseX::Storage; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | with qw(Geometry::Primitive::Equal MooseX::Clone MooseX::Storage::Deferred); | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 1 | ▶ | use overload ('""' => 'to_string'); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | has 'height' => ( | |||||||||||||||||||
| 11 | is => 'rw', | ||||||||||||||||||||
| 12 | isa => 'Num', | ||||||||||||||||||||
| 13 | default => 0, | ||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||
| 15 | 1 | has 'width' => ( | |||||||||||||||||||
| 16 | is => 'rw', | ||||||||||||||||||||
| 17 | isa => 'Num', | ||||||||||||||||||||
| 18 | default => 0 | ||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | coerce 'Geometry::Primitive::Dimension' | ||||||||||||||||||||
| 22 | => from 'ArrayRef' | ||||||||||||||||||||
| 23 | 0 | ▶ | => via { Geometry::Primitive::Dimension->new(width => $_->[0], height => $_->[1]) }; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 2 | ▶ | sub equal_to { | ||||||||||||||||||
|
Subroutine
equal_to: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 26 | 2 | my ($self, $other) = @_; | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 2 | ▶ | return (($self->width == $other->width) && $self->height == $other->height); | ||||||||||||||||||
|
Condition66%2/3
$self->width == $other->width && $self->height == $other->height
MC/DC50%1/2
$self->width == $other->width && $self->height == $other->height
$self->width == $other->width
$self->height == $other->height
Truth table66%2/3
A && B
A= $self->width == $other->widthB= $self->height == $other->height
| |||||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 0 | ▶ | sub to_string { | ||||||||||||||||||
|
Subroutine
to_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 32 | 0 | my ($self) = @_; | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | return $self->width.'x'.$self->height; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 1 | ▶ | no Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 40 | 1 | 1; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =head1 NAME | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | Geometry::Primitive::Dimension - A width and height | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =head1 DESCRIPTION | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | Geometry::Primitive::Dimension encapsulates a height and width. | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =head1 SYNOPSIS | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | use Geometry::Primitive::Dimension; | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | my $point = Geometry::Primitive::Dimeions->new(width => 100, height => 100); | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | =head1 ATTRIBUTES | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | =head2 height | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | Set/Get the height value. | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =head2 width | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | Set/Get the width value. | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | =head1 METHODS | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | =head2 new | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | Creates a new Geometry::Primitive::Point. | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | =head2 equal_to | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | Compares this dimesion to another. | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | =head2 to_string | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | Return this dimesion as a string $widthx$height | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | =head1 AUTHOR | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | Cory Watson <gphat@cpan.org> | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | You can redistribute and/or modify this code under the same terms as Perl | ||||||||||||||||||||
| 87 | itself. | ||||||||||||||||||||