File Coverage

blib/lib/SVG/Graph/Data/Tree.pm
Criterion Covered Total %
statement 19 22 86.3
branch 2 2 100.0
condition n/a
subroutine 6 7 85.7
pod 5 5 100.0
total 32 36 88.8


line stmt bran cond sub pod time code
1             package SVG::Graph::Data::Tree;
2              
3 1     1   825 use strict;
  1         2  
  1         35  
4 1     1   528 use SVG::Graph::Data::Node;
  1         4  
  1         235  
5              
6             =head2 new
7              
8             Title : new
9             Usage :
10             Function:
11             Example :
12             Returns :
13             Args :
14              
15              
16             =cut
17              
18             sub new {
19 1     1 1 225 my($class, @args) = @_;
20 1         11 my $self = bless {}, $class;
21 1         6 $self->init(@args);
22 1         3 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             sub init {
38 1     1 1 2 my($self, %args) = @_;
39              
40 1         11 $self->root(SVG::Graph::Data::Node->new);
41 1         3 $self->root->name('root');
42              
43 1         11 foreach my $arg (keys %args) {
44 0         0 $self->$arg($args{$arg});
45             }
46             }
47              
48             =head2 depth
49              
50             Title : depth
51             Usage :
52             Function:
53             Example :
54             Returns :
55             Args :
56              
57              
58             =cut
59              
60             sub depth{
61 0     0 1 0 my ($self,@args) = @_;
62              
63 0         0 return $self->root->depth;
64             }
65              
66             =head2 root
67              
68             Title : root
69             Usage : $obj->root($newval)
70             Function:
71             Example :
72             Returns : value of root (a scalar)
73             Args : on set, new value (a scalar or undef, optional)
74              
75              
76             =cut
77              
78             sub root{
79 4     4 1 195 my $self = shift;
80              
81 4 100       14 return $self->{'root'} = shift if @_;
82 3         19 return $self->{'root'};
83             }
84              
85             =head2 new_node
86              
87             Title : new_node
88             Usage :
89             Function:
90             Example :
91             Returns :
92             Args :
93              
94              
95             =cut
96              
97             sub new_node{
98 21     21 1 2001 my ($self,@args) = @_;
99              
100 21         73 return SVG::Graph::Data::Node->new(@args);
101             }
102              
103             1;