Construction/Vector.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 50.0% 1 / 2 totaltotal 93.4% 43 / 46 CC 4 SCAR 8.0
CC
4
Cov
95%
value
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« Construction/Derivate/IntersectionLineLine.pm ↑ Summary Construction/Line.pm »
1 package Math::Geometry::Construction::Vector;
2  
3 16 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 16 ▶use Math::Vector::Real;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use Math::Geometry::Construction::Types qw(MathVectorReal
Subroutine BEGIN: called CC=1 SCAR=0.0
7 Point
8 16 PointPoint);
9 16 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 16 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =head1 NAME
13  
14 C<Math::Geometry::Construction::Vector> - anything representing a vector
15  
16 =head1 VERSION
17  
18 Version 0.024
19  
20 =cut
21  
22 16 our $VERSION = '0.024';
23  
24  
25 ###########################################################################
26 # #
27 # Class Variables and Methods #
28 # #
29 ###########################################################################
30  
31 ###########################################################################
32 # #
33 # Accessors #
34 # #
35 ###########################################################################
36  
37 16 with 'Math::Geometry::Construction::Role::AlternativeSources';
38  
39 16 my %alternative_sources =
40 (value_sources => {'vector' => {isa => MathVectorReal,
41 coerce => 1},
42 'point' => {isa => Point},
43 'point_point' => {isa => PointPoint,
44 coerce => 1}});
45  
46 16 ▶while(my ($name, $alternatives) = each %alternative_sources) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %alternative_sources) 16 16 32
47 16 __PACKAGE__->alternatives
48 (name => $name,
49 alternatives => $alternatives,
50 clear_buffer => 0);
51 }
52  
53 318 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
54 318 my ($self, $args) = @_;
55  
56 318 $self->_check_value_sources;
57 }
58  
59 ###########################################################################
60 # #
61 # Retrieve Data #
62 # #
63 ###########################################################################
64  
65 554 ▶sub value {
Subroutine value: called CC=4 SCAR=14.0
Pod documented
66 554 my ($self) = @_;
67  
68 554 ▶ return $self->_vector if($self->_has_vector);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_vector 540 14 554
69 14 ▶ return $self->_point->position if($self->_has_point);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_point 10 4 14
70 4 ▶ if($self->_has_point_point) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_has_point_point) 4 0 4
71 4 my $points = $self->_point_point;
72 4 return $points->[1]->position - $points->[0]->position;
73 }
74 0 croak('No way to determine value of Vector, '.
75 'please send a bug report');
76 }
77 ###########################################################################
78 # #
79 # Change Data #
80 # #
81 ###########################################################################
82  
83 16 1;
84  
85  
86 __END__
« Construction/Derivate/IntersectionLineLine.pm ↑ Summary Construction/Line.pm »