| 1 | package YAX::Document; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 3 | ▶ | use YAX::Text; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use YAX::Element; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 3 | ▶ | use YAX::Fragment; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 3 | ▶ | use YAX::Constants qw/:all/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 3 | ▶ | use YAX::Query; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 3 | ▶ | use overload '@{}' => \&children, '%{}' => \&elements, fallback => 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | sub HASH () { 0 } | ||||||||||
| 14 | sub KIDS () { 1 } | ||||||||||
| 15 | #sub TYPE () { 3 } | ||||||||||
| 16 | |||||||||||
| 17 | 2 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 18 | 2 | my $class = shift; | |||||||||
| 19 | 2 | my $self = bless \[ { }, [ ], '' ], $class; | |||||||||
| 20 | 2 | return $self; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 4 | ▶ | sub type { DOCUMENT_NODE } | ||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 24 | 0 | ▶ | sub name { '#document' } | ||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub document { $_[0] } | ||||||||
|
Subroutine
document: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 27 | |||||||||||
| 28 | 10 | ▶ | sub elements { | ||||||||
|
Subroutine
elements: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 29 | 10 | my $self = shift; | |||||||||
| 30 | 10 | $$self->[HASH]; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 22 | ▶ | sub children { | ||||||||
|
Subroutine
children: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 34 | 22 | my $self = shift; | |||||||||
| 35 | 22 | $$self->[KIDS]; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub parent { undef } | ||||||||
|
Subroutine
parent: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 39 | |||||||||||
| 40 | #sub doctype { | ||||||||||
| 41 | # my $self = shift; | ||||||||||
| 42 | # $$self->[TYPE] = shift if @_; | ||||||||||
| 43 | # $$self->[TYPE]; | ||||||||||
| 44 | #} | ||||||||||
| 45 | |||||||||||
| 46 | 7 | ▶ | sub set { | ||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 47 | 7 | my ( $self, $id, $elmt ) = @_; | |||||||||
| 48 | 7 | $self->elements->{$id} = $elmt; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 1 | ▶ | sub get { | ||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 52 | 1 | my ( $self, $id ) = @_; | |||||||||
| 53 | 1 | return $self->elements->{$id}; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 3 | ▶ | sub root { | ||||||||
|
Subroutine
root: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||
| 57 | 3 | my ( $self ) = @_; | |||||||||
| 58 | 3 | foreach my $node ( @$self ) { | |||||||||
| 59 | 7 | ▶ | return $node if $node->type == ELEMENT_NODE; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | } | ||||||||||
| 61 | 0 | return undef; | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | sub text { | ||||||||
|
Subroutine
text: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 65 | 0 | my ( $self, $text ) = @_; | |||||||||
| 66 | 0 | my $node = YAX::Text->new( $text ); | |||||||||
| 67 | 0 | return $node; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub element { | ||||||||
|
Subroutine
element: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 71 | 0 | my ( $self, $name, %atts ) = @_; | |||||||||
| 72 | 0 | my $node = YAX::Element->new( $name, %atts ); | |||||||||
| 73 | 0 | return $node; | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 0 | ▶ | sub fragment { | ||||||||
|
Subroutine
fragment: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 77 | 0 | my $self = shift; | |||||||||
| 78 | 0 | my $frag = YAX::Fragment->new(@_); | |||||||||
| 79 | 0 | return $frag; | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 3 | *query = \&YAX::Element::query; | |||||||||
| 83 | 3 | *append = \&YAX::Element::append; | |||||||||
| 84 | 3 | *replace = \&YAX::Element::replace; | |||||||||
| 85 | 3 | *remove = \&YAX::Element::remove; | |||||||||
| 86 | 3 | *insert = \&YAX::Element::insert; | |||||||||
| 87 | 3 | *_claim_child = \&YAX::Element::_claim_child; | |||||||||
| 88 | |||||||||||
| 89 | 0 | ▶ | sub as_string { | ||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 90 | 0 | my $self = shift; | |||||||||
| 91 | 0 | my @kids = @{ $self->children }; | |||||||||
| 92 | 0 | my $kids = join('', map { $_->as_string } @{ $self->children }); | |||||||||
| 93 | 0 | join( '', $kids ); | |||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | 3 | 1; | |||||||||
| 97 | |||||||||||
| 98 | __END__ | ||||||||||