Primitive/Point.pm

filter: Statementstmt 100% 26 / 26 Branchbran n/a Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 95.1% 39 / 41 CC 2 SCAR 2.1
CC
2
Cov
97%
equal_to
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Primitive/Ellipse.pm ↑ Summary Primitive/Bezier.pm »
1 package Geometry::Primitive::Point;
2 8 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 8 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use MooseX::Storage;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 with qw(Geometry::Primitive::Equal MooseX::Clone MooseX::Storage::Deferred);
7  
8 8 ▶use overload ('""' => 'to_string');
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 has 'x' => (
11 is => 'rw',
12 isa => 'Num'
13 );
14 8 has 'y' => (
15 is => 'rw',
16 isa => 'Num'
17 );
18  
19 coerce 'Geometry::Primitive::Point'
20 => from 'ArrayRef'
21 11 ▶ => via { Geometry::Primitive::Point->new(x => $_->[0], y => $_->[1]) };
Subroutine __ANON__: called CC=1 SCAR=0.0
22  
23 11 ▶sub equal_to {
Subroutine equal_to: called CC=2 SCAR=7.1
Pod documented
24 11 my ($self, $other) = @_;
25  
26 11 ▶ return (($self->x == $other->x) && $self->y == $other->y);
Condition66%2/3
$self->x == $other->x && $self->y == $other->y
!ll&&!rl&&r
1010
MC/DC50%1/2
$self->x == $other->x && $self->y == $other->y
$self->x == $other->x $self->y == $other->y
Truth table66%2/3
A && B
A= $self->x == $other->xB= $self->y == $other->y
ABresult
0X0
100
111
27 }
28  
29 22 ▶sub to_string {
Subroutine to_string: called CC=1 SCAR=0.0
Pod documented
30 22 my ($self) = @_;
31  
32 22 return $self->x.','.$self->y;
33 }
34  
35 8 __PACKAGE__->meta->make_immutable;
36  
37 8 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 8 1;
39  
40 =head1 NAME
41  
42 Geometry::Primitive::Point - An XY coordinate
43  
44 =head1 DESCRIPTION
45  
46 Geometry::Primitive::Point represents a location in two dimensional space.
47  
48 =head1 SYNOPSIS
49  
50 use Geometry::Primitive::Point;
51  
52 my $point = Geometry::Primitive::Point->new({ x => 2, y => 0 });
53  
54 =head1 ATTRIBUTES
55  
56 =head2 x
57  
58 Set/Get the X value.
59  
60 =head2 y
61  
62 Set/Get the Y value.
63  
64 =head1 METHODS
65  
66 =head2 new
67  
68 Creates a new Geometry::Primitive::Point.
69  
70 =head2 equal_to
71  
72 Compares this point to another.
73  
74 =head2 to_string
75  
76 Return this point as a string $x,$y
77  
78 =head1 AUTHOR
79  
80 Cory Watson <gphat@cpan.org>
81  
82 =head1 COPYRIGHT & LICENSE
83  
84 You can redistribute and/or modify this code under the same terms as Perl
85 itself.
« Primitive/Ellipse.pm ↑ Summary Primitive/Bezier.pm »