File Coverage

lib/SVG/Estimate/Path/Command.pm
Criterion Covered Total %
statement 3 11 27.2
branch n/a
condition n/a
subroutine 1 2 50.0
pod 0 1 0.0
total 4 14 28.5


line stmt bran cond sub pod time code
1             package SVG::Estimate::Path::Command;
2             $SVG::Estimate::Path::Command::VERSION = '1.0107';
3 16     16   5292 use Moo;
  16         19  
  16         72  
4             with 'SVG::Estimate::Role::Round';
5              
6              
7             =head1 NAME
8              
9             SVG::Estimate::Path::Command - Base class for all path calculations.
10              
11             =head1 VERSION
12              
13             version 1.0107
14              
15             =head1 DESCRIPTION
16              
17             There are a lot of methods and parameters shared between the various shape classes in L. This base class encapsulates them all.
18              
19             =head1 INHERITANCE
20              
21             This class consumes L.
22              
23             =head1 METHODS
24              
25             =head2 new( properties )
26              
27             Constructor.
28              
29             =over
30              
31             =item properties
32              
33             =over
34              
35             =item start_point
36              
37             An array ref that describes the position of the cursor (or CNC head) prior to drawing this path (where it left off from the last object).
38              
39             =item transformer
40              
41             A reference to a L object that contains all the transforms for this path segment.
42              
43             =back
44              
45             =back
46              
47             =cut
48              
49             has start_point => (
50             is => 'ro',
51             required => 1,
52             );
53              
54             has transformer => (
55             is => 'ro',
56             required => 1,
57             );
58              
59             =head2 end_point ( )
60              
61             Returns an array ref that contains an end point of where this command left off to fill the C of the next command.
62              
63             =cut
64              
65             has end_point => (
66             is => 'ro',
67             required => 1,
68             );
69              
70             =head2 shape_length ( )
71              
72             Returns the total shape length of the vector in the path command.
73              
74             =cut
75              
76             has shape_length => (
77             is => 'ro',
78             required => 1,
79             );
80              
81             =head2 travel_length ( )
82              
83             Returns the total travel length of the vector in the path command.
84              
85             =cut
86              
87             has travel_length => (
88             is => 'ro',
89             required => 1,
90             );
91              
92             =head2 min_x ( )
93              
94             Returns the minimum position of C that this path segment will ever reach.
95              
96             =cut
97              
98             has min_x => (
99             is => 'ro',
100             required => 1,
101             );
102              
103             =head2 max_x ( )
104              
105             Returns the maximum position of C that this path segment will ever reach.
106              
107             =cut
108              
109             has max_x => (
110             is => 'ro',
111             required => 1,
112             );
113              
114             =head2 min_y ( )
115              
116             Returns the minimum position of C that this path segment will ever reach.
117              
118             =cut
119              
120             has min_y => (
121             is => 'ro',
122             required => 1,
123             );
124              
125             =head2 max_y ( )
126              
127             Returns the max position of C that this path segment will ever reach.
128              
129             =cut
130              
131             has max_y => (
132             is => 'ro',
133             required => 1,
134             );
135              
136             has summarize => (
137             is => 'ro',
138             default => sub { 0 },
139             );
140              
141             sub summarize_myself {
142 0     0 0   my $self = shift;
143 0           print "\t".ref $self;
144 0           printf "\n\t\tstart point: [%s, %s]", $self->round($self->start_point->[0]), $self->round($self->start_point->[1]);
145 0           printf "\n\t\tend point: [%s, %s]", $self->round($self->end_point->[0]), $self->round($self->end_point->[1]);
146 0           print "\n\t\ttotal length: ". $self->round($self->travel_length + $self->shape_length);
147 0           print "\n\t\ttravel length: ". $self->round($self->travel_length);
148 0           print "\n\t\tshape length: ". $self->round($self->shape_length);
149 0           print "\n";
150             }
151              
152             1;