| 1 | package YAX::Builder; | ||||||||||||||
| 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 | |||||||||||||||
| 9 | 0 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 10 | 0 | my ( $class ) = @_; | |||||||||||||
| 11 | 0 | my $self = bless { }, $class; | |||||||||||||
| 12 | 0 | $self; | |||||||||||||
| 13 | } | ||||||||||||||
| 14 | |||||||||||||||
| 15 | 5 | ▶ | sub build { | ||||||||||||
|
Subroutine
build: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||
| 16 | 5 | my ( $self, @specs ) = @_; | |||||||||||||
| 17 | 5 | my @nodes = map { $self->node( $_ ) } @specs; | |||||||||||||
| 18 | 5 | ▶ | return wantarray ? @nodes : $nodes[0]; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 19 | } | ||||||||||||||
| 20 | |||||||||||||||
| 21 | 10 | ▶ | sub node { | ||||||||||||
|
Subroutine
node: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||
| 22 | 10 | my ( $self, $spec ) = @_; | |||||||||||||
| 23 | 10 | ▶ | if ( ref $spec eq 'ARRAY' ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 24 | 5 | my @copy = @$spec; | |||||||||||||
| 25 | 5 | my $name = splice @copy, 0, 1; | |||||||||||||
| 26 | 5 | ▶ | my %atts = ref $copy[0] eq 'HASH' ? %{ splice @copy, 0, 1 } : ( ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 27 | |||||||||||||||
| 28 | 5 | my $node = $self->element( $name, %atts ); | |||||||||||||
| 29 | 5 | $node->append( $_ ) for $self->build( @copy ); | |||||||||||||
| 30 | 5 | return $node; | |||||||||||||
| 31 | } | ||||||||||||||
| 32 | elsif ( UNIVERSAL::isa( $spec, 'YAX::Node' ) ) { | ||||||||||||||
| 33 | 2 | return $spec; | |||||||||||||
| 34 | } | ||||||||||||||
| 35 | else { | ||||||||||||||
| 36 | 3 | return $self->text( $spec ); | |||||||||||||
| 37 | } | ||||||||||||||
| 38 | } | ||||||||||||||
| 39 | |||||||||||||||
| 40 | 3 | ▶ | sub text { | ||||||||||||
|
Subroutine
text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 41 | 3 | my $self = shift; | |||||||||||||
| 42 | 3 | YAX::Text->new(@_); | |||||||||||||
| 43 | } | ||||||||||||||
| 44 | |||||||||||||||
| 45 | 5 | ▶ | sub element { | ||||||||||||
|
Subroutine
element: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 46 | 5 | my ( $self, $name, %atts ) = @_; | |||||||||||||
| 47 | 5 | YAX::Element->new( $name, %atts ); | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | |||||||||||||||
| 50 | 0 | ▶ | sub fragment { | ||||||||||||
|
Subroutine
fragment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 51 | 0 | my ( $self, @kids ) = @_; | |||||||||||||
| 52 | 0 | YAX::Fragment->new( $self->build( @kids ) ); | |||||||||||||
| 53 | } | ||||||||||||||
| 54 | |||||||||||||||
| 55 | 3 | 1; | |||||||||||||
| 56 | __END__ | ||||||||||||||