Graph/Glyph.pm

filter: Statementstmt 94.5% 52 / 55 Branchbran 91.6% 22 / 24 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 93.3% 14 / 15 Podpod 100% 12 / 12 totaltotal 90.5% 105 / 116 CC 16 SCAR 10.8
CC
16
Cov
92%
_style
6.3
init
4.0
draw
2.0
CRAP 3.0
« Graph/Glyph/line.pm ↑ Summary Graph/Data.pm »
1 package SVG::Graph::Glyph;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head2 new
7  
8 Title : new
9 Usage :
10 Function:
11 Example :
12 Returns :
13 Args :
14  
15  
16 =cut
17  
18 14 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
19 14 my($class, %args) = @_;
20 14 my $self = bless {}, $class;
21 14 $self->init(%args);
22 14 return $self;
23 }
24  
25 =head2 init
26  
27 Title : init
28 Usage :
29 Function:
30 Example :
31 Returns :
32 Args :
33  
34  
35 =cut
36  
37 14 ▶sub init {
Subroutine init: called CC=4 SCAR=13.9
Pod documented
38 14 my($self, %args) = @_;
39  
40 14 my $id = sprintf("%07d",int(rand(9999999)));
41 14 my($glyphname) = ref($self) =~ /::([^:]+)$/;
42  
43  
44 14 foreach my $arg (keys %args){
45 94 my $meth = $arg;
46 #caveat, all constructor args will now pass
47 94 ▶ if($self->can($meth)){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($meth)) { } 84 10 94
48 84 $self->$meth($args{$arg});
49 } else {
50 10 $self->_style($arg => $args{$arg});
51 }
52 }
53  
54 14 ▶ $self->canvas($self->svg->group(id=>"$glyphname$id")) unless $self->canvas;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->canvas 14 0 14
55 }
56  
57 =head2 _style
58  
59 Title : _style
60 Usage : $obj->_style($newval)
61 Function:
62 Example :
63 Returns :
64 Args :
65  
66  
67 =cut
68  
69 200 ▶sub _style{
Subroutine _style: called CC=6 SCAR=18.4
70 200 my $self = shift;
71 200 my($key,$val) = @_;
72  
73 200 ▶ if(defined($key) and not defined($val)){
Branch: 2 branches
BranchTrueFalseTotal
if (defined $key and not defined $val) { } 0 200 200
elsif (defined $key and defined $val) { } 10 190 200
Condition66%2/3
defined $key and not defined $val
!ll&&!rl&&r
190100
MC/DC0%0/2
defined $key and not defined $val
defined $key not defined $val
Truth table66%2/3
A and not(B)
A= defined $keyB= not defined $val
ABresult
0X0
100
111
74 0 return $self->{'_style'}{$key};
75 ▶ } elsif(defined($key) and defined($val)){
Condition66%2/3
defined $key and defined $val
!ll&&!rl&&r
190010
MC/DC50%1/2
defined $key and defined $val
defined $key defined $val
Truth table66%2/3
A and B
A= defined $keyB= defined $val
ABresult
0X0
100
111
76 10 $self->{'_style'}{$key} = $val;
77 10 return $val;
78 } else {
79 190 ▶ return $self->{'_style'} ? %{$self->{'_style'}} : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_style'} ? : 104 86 190
80 }
81 }
82  
83 =head2 draw
84  
85 Title : draw
86 Usage :
87 Function:
88 Example :
89 Returns :
90 Args :
91  
92  
93 =cut
94  
95 0 ▶sub draw{
Subroutine draw: not called CC=1 SCAR=6.9
Pod documented
96 0 my ($self,@args) = @_;
97  
98 0 die "method undefined by ".__PACKAGE__;
99 }
100  
101 =head2 svg
102  
103 Title : svg
104 Usage : $obj->svg($newval)
105 Function:
106 Example :
107 Returns : value of svg (a scalar)
108 Args : on set, new value (a scalar or undef, optional)
109  
110  
111 =cut
112  
113 61 ▶sub svg{
Subroutine svg: called CC=2 SCAR=6.9
Pod documented
114 61 my $self = shift;
115  
116 61 ▶ return $self->{'svg'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 14 47 61
117 47 return $self->{'svg'};
118 }
119  
120 =head2 group
121  
122 Title : group
123 Usage : $obj->group($newval)
124 Function:
125 Example :
126 Returns : value of group (a scalar)
127 Args : on set, new value (a scalar or undef, optional)
128  
129  
130 =cut
131  
132 450 ▶sub group{
Subroutine group: called CC=2 SCAR=6.9
Pod documented
133 450 my $self = shift;
134  
135 450 ▶ return $self->{'group'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 14 436 450
136 436 return $self->{'group'};
137 }
138  
139 =head2 xsize
140  
141 Title : xsize
142 Usage : $obj->xsize($newval)
143 Function:
144 Example :
145 Returns : value of xsize (a scalar)
146 Args : on set, new value (a scalar or undef, optional)
147  
148  
149 =cut
150  
151 172 ▶sub xsize{
Subroutine xsize: called CC=2 SCAR=6.9
Pod documented
152 172 my $self = shift;
153  
154 172 ▶ return $self->{'xsize'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 14 158 172
155 158 return $self->{'xsize'};
156 }
157  
158 =head2 ysize
159  
160 Title : ysize
161 Usage : $obj->ysize($newval)
162 Function:
163 Example :
164 Returns : value of ysize (a scalar)
165 Args : on set, new value (a scalar or undef, optional)
166  
167  
168 =cut
169  
170 118 ▶sub ysize{
Subroutine ysize: called CC=2 SCAR=6.9
Pod documented
171 118 my $self = shift;
172  
173 118 ▶ return $self->{'ysize'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 14 104 118
174 104 return $self->{'ysize'};
175 }
176  
177 =head2 xoffset
178  
179 Title : xoffset
180 Usage : $obj->xoffset($newval)
181 Function:
182 Example :
183 Returns : value of xoffset (a scalar)
184 Args : on set, new value (a scalar or undef, optional)
185  
186  
187 =cut
188  
189 211 ▶sub xoffset{
Subroutine xoffset: called CC=2 SCAR=6.9
Pod documented
190 211 my $self = shift;
191  
192 211 ▶ return $self->{'xoffset'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 14 197 211
193 197 return $self->{'xoffset'};
194 }
195  
196 =head2 yoffset
197  
198 Title : yoffset
199 Usage : $obj->yoffset($newval)
200 Function:
201 Example :
202 Returns : value of yoffset (a scalar)
203 Args : on set, new value (a scalar or undef, optional)
204  
205  
206 =cut
207  
208 211 ▶sub yoffset{
Subroutine yoffset: called CC=2 SCAR=6.9
Pod documented
209 211 my $self = shift;
210  
211 211 ▶ return $self->{'yoffset'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 14 197 211
212 197 return $self->{'yoffset'};
213 }
214  
215 =head2 xscale
216  
217 Title : xscale
218 Usage :
219 Function:
220 Example :
221 Returns :
222 Args :
223  
224  
225 =cut
226  
227 20 ▶sub xscale{
Subroutine xscale: called CC=1 SCAR=0.0
Pod documented
228 20 my ($self,@args) = @_;
229  
230 20 return $self->xsize / $self->group->xrange;
231 }
232  
233 =head2 yscale
234  
235 Title : yscale
236 Usage :
237 Function:
238 Example :
239 Returns :
240 Args :
241  
242  
243 =cut
244  
245 20 ▶sub yscale{
Subroutine yscale: called CC=1 SCAR=0.0
Pod documented
246 20 my ($self,@args) = @_;
247  
248 20 return $self->ysize / $self->group->yrange;
249 }
250  
251 =head2 canvas
252  
253 Title : canvas
254 Usage : $obj->canvas($newval)
255 Function:
256 Example :
257 Returns : value of canvas (a scalar)
258 Args : on set, new value (a scalar or undef, optional)
259  
260  
261 =cut
262  
263 28 ▶sub canvas{
Subroutine canvas: called CC=2 SCAR=6.9
Pod documented
264 28 my $self = shift;
265  
266 28 ▶ return $self->{'canvas'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 14 14 28
267 14 return $self->{'canvas'};
268 }
269  
270  
271 7 1;
« Graph/Glyph/line.pm ↑ Summary Graph/Data.pm »