DOM/NodeList.pm

filter: Statementstmt 100% 22 / 22 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 66.6% 2 / 3 totaltotal 94.2% 33 / 35 SCAR 6.9
CC
2
Cov
96%
item
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« DOM/_FieldHash.pm ↑ Summary DOM/Event/Mouse.pm »
1 package HTML::DOM::NodeList;
2  
3 29 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 29 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 29 ▶use overload fallback => 1, '@{}' => sub { ${$_[0]} };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
6  
7 29 ▶use Scalar::Util 'weaken';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 29 our $VERSION = '0.057';
10  
11  
12 # new NodeList \@array;
13  
14 sub new {
15 74 ▶ bless do {\(my $x = $_[1])}, shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
16 }
17  
18 sub item {
19 349 ▶ ${$_[0]}[$_[1]] || ()
Subroutine item: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${$_[0];}[$_[1]] or () 0 349 349
20 }
21  
22 sub length {
23 67 ▶ scalar @${$_[0]}
Subroutine length: called CC=1 SCAR=0.0
Pod documented
24 }
25  
26 29 1 __END__
27  
28 =head1 NAME
29  
30 HTML::DOM::NodeList - Simple node list class for HTML::DOM
31  
32 =head1 VERSION
33  
34 Version 0.057
35  
36 =head1 SYNOPSIS
37  
38 use HTML::DOM;
39 $doc = HTML::DOM->new;
40  
41 $list = $doc->body->childNodes; # returns an HTML::DOM::NodeList
42
43 $list->[0]; # first node
44 $list->item(0); # same
45
46 $list->length; # same as scalar @$list
47  
48 =head1 DESCRIPTION
49  
50 This implements the NodeList interface as described in the W3C's DOM
51 standard. In addition to the methods below, you can use a node list object
52 as an array.
53  
54 This class actually only implements those node lists that are based on
55 array references (as returned by C<childNodes> methods). The
56 L<HTML::DOM::NodeList::Magic> class is used for more
57 complex node lists that call a code ref to update themselves. This is an
58 implementation detail though, that you shouldn't have to worry about.
59  
60 =head1 OBJECT METHODS
61  
62 =over 4
63  
64 =item $list->length
65  
66 Returns the number of items in the array.
67  
68 =item $list->item($index)
69  
70 Returns item number C<$index>, numbered from 0. Note that you can also use
71 C<< $list->[$index] >> for short.
72  
73 =back
74  
75 =head1 SEE ALSO
76  
77 L<HTML::DOM>
78  
79 L<HTML::DOM::NodeList::Magic>
80  
81 L<HTML::DOM::Node>
82  
83 L<HTML::DOM::Collection>
« DOM/_FieldHash.pm ↑ Summary DOM/Event/Mouse.pm »