File Coverage

blib/lib/XML/DOM2/Element/Comment.pm
Criterion Covered Total %
statement 9 27 33.3
branch n/a
condition 0 8 0.0
subroutine 3 10 30.0
pod 5 5 100.0
total 17 50 34.0


line stmt bran cond sub pod time code
1             package XML::DOM2::Element::Comment;
2              
3             =head1 NAME
4              
5             XML::DOM2::Element::Comment
6              
7             =head1 DISCRIPTION
8              
9             Comment element object class.
10              
11             =head1 METHODS
12              
13             =cut
14              
15 3     3   20 use base "XML::DOM2::Element";
  3         7  
  3         259  
16              
17 3     3   18 use strict;
  3         6  
  3         92  
18 3     3   17 use warnings;
  3         6  
  3         1103  
19              
20             =head2 $element->new( $name, %options )
21              
22             Create a new comment element object.
23              
24             =cut
25             sub new
26             {
27 0     0 1   my ($proto, $text, %args) = @_;
28 0           $args{'text'} = $text;
29 0           my $self = $proto->SUPER::new('comment', %args);
30 0           return $self;
31             }
32              
33             =head2 $element->xmlify()
34              
35             Returns the comment as xml.
36              
37             =cut
38             sub xmlify
39             {
40 0     0 1   my ($self, %p) = @_;
41 0   0       my $sep = $p{'seperator'} || "\n";
42 0   0       my $indent = ($p{'indent'} || ' ') x ( $p{'level'} || 0 );
      0        
43 0           my $text = $self->{'text'};
44 0           $text =~ s/$sep/$sep$indent/g;
45 0           return $sep.$indent.'';
46             }
47              
48             =head2 $element->text()
49              
50             Return plain text (UTF-8)
51              
52             =cut
53             sub text
54             {
55 0     0 1   my ($self) = @_;
56 0   0       return $self->{'text'} || '';
57             }
58              
59             =head2 $element->setComment( $text )
60              
61             Replace comment with $text
62              
63             =cut
64             sub setComment
65             {
66 0     0 1   my ($self, $text) = @_;
67 0           $self->{'text'} = $text;
68             }
69              
70             =head2 $element->appendComment( $text )
71              
72             Append to the end of existing comment text $text
73              
74             =cut
75             sub appendComment
76             {
77 0     0 1   my ($self, $text) = @_;
78 0           $self->{'text'} .= $text;
79             }
80              
81             =head2 $element->_can_contain_elements()
82              
83             The element can not contain sub elements.
84              
85             =cut
86 0     0     sub _can_contain_elements { 0 }
87              
88             =head2 $element->_can_contain_attributes()
89              
90             The element can not contain attributes
91              
92             =cut
93 0     0     sub _can_contain_attributes { 0 }
94              
95             =head1 COPYRIGHT
96              
97             Martin Owens, doctormo@cpan.org
98              
99             =head1 SEE ALSO
100              
101             L,L
102              
103             =cut
104             1;