File Coverage

blib/lib/Pod/Simple/PullParserStartToken.pm
Criterion Covered Total %
statement 17 24 70.8
branch 3 8 37.5
condition 1 7 14.2
subroutine 8 10 80.0
pod 6 7 85.7
total 35 56 62.5


line stmt bran cond sub pod time code
1             package Pod::Simple::PullParserStartToken;
2 10     10   62 use strict;
  10         20  
  10         382  
3 10     10   68 use warnings;
  10         22  
  10         593  
4 10     10   5287 use Pod::Simple::PullParserToken ();
  10         28  
  10         3144  
5             our @ISA = ('Pod::Simple::PullParserToken');
6             our $VERSION = '3.47';
7              
8             sub new { # Class->new(tagname, optional_attrhash);
9 349     349 0 1005 my $class = shift;
10 349   33     1927 return bless ['start', @_], ref($class) || $class;
11             }
12              
13             # Purely accessors:
14              
15 474 50   474 1 2960 sub tagname { (@_ == 2) ? ($_[0][1] = $_[1]) : $_[0][1] }
16 3     3 1 6 sub tag { shift->tagname(@_) }
17              
18 2     2 1 11 sub is_tagname { $_[0][1] eq $_[1] }
19 0     0 1 0 sub is_tag { shift->is_tagname(@_) }
20              
21              
22 0   0 0 1 0 sub attr_hash { $_[0][2] ||= {} }
23              
24             sub attr {
25 82 50   82 1 108 if(@_ == 2) { # Reading: $token->attr('attrname')
    0          
26 82 50       83 ${$_[0][2] || return undef}{ $_[1] };
  82         211  
27             } elsif(@_ > 2) { # Writing: $token->attr('attrname', 'newval')
28 0   0       ${$_[0][2] ||= {}}{ $_[1] } = $_[2];
  0            
29             } else {
30 0           require Carp;
31 0           Carp::croak(
32             'usage: $object->attr("val") or $object->attr("key", "newval")');
33 0           return undef;
34             }
35             }
36              
37             1;
38              
39              
40             __END__