| 1 | package YAX::Text; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 3 | ▶ | use base qw/YAX::Node/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 3 | ▶ | use Scalar::Util qw/weaken/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 3 | ▶ | use YAX::Constants qw/TEXT_NODE/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 3 | ▶ | use overload '""' => \&as_string, fallback => 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | sub TEXT () { 0 } | ||||||||||
| 13 | sub PRNT () { 1 } | ||||||||||
| 14 | |||||||||||
| 15 | 51 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 16 | 51 | my ( $class, $data ) = @_; | |||||||||
| 17 | 51 | bless [ $data, undef ], $class; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 6 | ▶ | sub type { TEXT_NODE } | ||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 21 | 414 | ▶ | sub name { '#text' } | ||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 4 | ▶ | sub data { $_[0][TEXT] = $_[1] if @_ == 2; $_[0][TEXT] } | ||||||||
|
Subroutine
data: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||
| 23 | |||||||||||
| 24 | 0 | ▶ | sub clone { | ||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 25 | 0 | my $self = shift; | |||||||||
| 26 | 0 | return ref( $self )->new( $self->data ); | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 54 | ▶ | sub parent { weaken( $_[0][PRNT] = $_[1] ) if @_ == 2; $_[0][PRNT] } | ||||||||
|
Subroutine
parent: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 4 | ▶ | sub as_string { | ||||||||
|
Subroutine
as_string: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||
| 32 | 4 | ▶ | return '' unless defined $_[0][TEXT]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 4 | ▶ | return '' unless length ($_[0][TEXT]); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 4 | $_[0][TEXT]; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub entityfy { | ||||||||
|
Subroutine
entityfy: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 38 | 0 | my $text = shift; | |||||||||
| 39 | 0 | $text =~ s/&/&/g; | |||||||||
| 40 | 0 | $text =~ s/</</g; | |||||||||
| 41 | 0 | $text =~ s/>/>/g; | |||||||||
| 42 | 0 | $text =~ s/'/'/g; | |||||||||
| 43 | 0 | $text =~ s/"/"/g; | |||||||||
| 44 | 0 | $text; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 3 | 1; | |||||||||
| 48 | __END__ | ||||||||||