File Coverage

blib/lib/SVG/Graph/Data/Datum.pm
Criterion Covered Total %
statement 19 26 73.0
branch 6 12 50.0
condition n/a
subroutine 6 8 75.0
pod 7 7 100.0
total 38 53 71.7


line stmt bran cond sub pod time code
1             package SVG::Graph::Data::Datum;
2              
3 6     6   5060 use strict;
  6         11  
  6         2333  
4             #use overload
5             # '""' => \&label,
6             # '<=>' => sub { my($x,$y) = ✓ $x <=> $y },
7             # '+' => sub { my($x,$y) = ✓ $x+$y },
8             # '-' => sub { my($x,$y) = ✓ $x-$y },
9             # '*' => sub { my($x,$y) = ✓ $x*$y },
10             # '/' => sub { my($x,$y) = ✓ $x/$y },
11             # ;
12              
13             =head2 new
14              
15             Title : new
16             Usage :
17             Function:
18             Example :
19             Returns :
20             Args :
21              
22              
23             =cut
24              
25             sub new {
26 180     180 1 2021 my($class, %args) = @_;
27 180         465 my $self = bless {}, $class;
28 180         526 $self->init(%args);
29 180         568 return $self;
30             }
31              
32             =head2 init
33              
34             Title : init
35             Usage :
36             Function:
37             Example :
38             Returns :
39             Args :
40              
41              
42             =cut
43              
44             sub init {
45 180     180 1 363 my($self, %args) = @_;
46 180         359 foreach my $arg (keys %args) {
47 540         1070 $self->$arg($args{$arg});
48             }
49             }
50              
51             =head2 x
52              
53             Title : x
54             Usage :
55             Function:
56             Example :
57             Returns :
58             Args :
59              
60              
61             =cut
62              
63             sub x {
64 836     836 1 1069 my($self,$arg) = @_;
65 836 100       1683 $self->{x} = $arg if defined $arg;
66 836         2157 return $self->{x};
67             }
68              
69             =head2 y
70              
71             Title : y
72             Usage :
73             Function:
74             Example :
75             Returns :
76             Args :
77              
78              
79             =cut
80              
81             sub y {
82 500     500 1 638 my($self,$arg) = @_;
83 500 100       1030 $self->{y} = $arg if defined $arg;
84 500         1268 return $self->{y};
85             }
86              
87             =head2 z
88              
89             Title : z
90             Usage :
91             Function:
92             Example :
93             Returns :
94             Args :
95              
96              
97             =cut
98              
99             sub z {
100 440     440 1 544 my($self,$arg) = @_;
101 440 100       909 $self->{z} = $arg if defined $arg;
102 440         1120 return $self->{z};
103             }
104              
105             =head2 label
106              
107             Title : label
108             Usage :
109             Function:
110             Example :
111             Returns :
112             Args :
113              
114              
115             =cut
116              
117             sub label {
118 0     0 1   my($self,$arg) = @_;
119 0 0         $self->{label} = $arg if defined $arg;
120 0           return $self->{label};
121             }
122              
123             =head2 check
124              
125             Title : check
126             Usage :
127             Function:
128             Example :
129             Returns :
130             Args :
131              
132              
133             =cut
134              
135             sub check {
136 0     0 1   my($x,$y) = @_;
137              
138 0 0         $x = $x->x if ref $x eq __PACKAGE__;
139 0 0         $y = $y->x if ref $y eq __PACKAGE__;
140              
141 0           return($x,$y);
142             }
143              
144             1;