| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/Literal.pm | ||||||||||
| 3 | ## Version v0.2.0 | ||||||||||
| 4 | ## Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||
| 6 | ## Created 2021/04/22 | ||||||||||
| 7 | ## Modified 2022/09/18 | ||||||||||
| 8 | ## All rights reserved. | ||||||||||
| 9 | ## | ||||||||||
| 10 | ## | ||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||
| 14 | package HTML::Object::Literal; | ||||||||||
| 15 | BEGIN | ||||||||||
| 16 | 13 | ▶ | { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 13 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 13 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 13 | warnings::register_categories( 'HTML::Object' ); | |||||||||
| 20 | 13 | ▶ | use parent qw( Module::Generic::Scalar ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 13 | ▶ | use vars qw( $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 13 | our $VERSION = 'v0.2.0'; | |||||||||
| 23 | }; | ||||||||||
| 24 | |||||||||||
| 25 | 13 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 13 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub as_number { return( shift->to_number( @_ ) ); } | ||||||||
|
Subroutine
as_number: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | |||||||||||
| 30 | sub as_string | ||||||||||
| 31 | 0 | ▶ | { | ||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 32 | 0 | my $self = shift( @_ ); | |||||||||
| 33 | 0 | my $txt = $self->SUPER::as_string; | |||||||||
| 34 | # $txt =~ s/'/'/g; | ||||||||||
| 35 | 0 | $txt =~ s/(?<!\\)\'/\\\'/g; | |||||||||
| 36 | 0 | return( "'$txt'" ); | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | sub as_xml | ||||||||||
| 40 | 0 | ▶ | { | ||||||||
|
Subroutine
as_xml: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 41 | 0 | my $self = shift( @_ ); | |||||||||
| 42 | 0 | my $txt = $self->SUPER::as_string; | |||||||||
| 43 | 0 | return( "<Literal>$txt</Literal>\n" ); | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | sub evaluate { return( shift( @_ ) ); } | ||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | sub getAttributes { return( shift->error( 'Cannot get attributes of a literal' ) ); } | ||||||||
|
Subroutine
getAttributes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub getChildNodes { return( shift->error( 'Cannot get child nodes of a literal' ) ); } | ||||||||
|
Subroutine
getChildNodes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub getParentNode { return( shift->error( 'Cannot get parent node of a literal' ) ); } | ||||||||
|
Subroutine
getParentNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub string_value { return( shift->value ); } | ||||||||
|
Subroutine
string_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 55 | |||||||||||
| 56 | # sub to_boolean { return( shift->as_boolean ); } | ||||||||||
| 57 | sub to_boolean | ||||||||||
| 58 | 0 | ▶ | { | ||||||||
|
Subroutine
to_boolean: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 59 | 0 | require HTML::Object::Boolean; | |||||||||
| 60 | 0 | ▶ | return( shift->as_string ? HTML::Object::Boolean->True : HTML::Object::Boolean->False ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | sub to_literal { return( shift( @_ ) ); } | ||||||||
|
Subroutine
to_literal: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 64 | |||||||||||
| 65 | # sub to_number { return( shift->as_number ); } | ||||||||||
| 66 | sub to_number | ||||||||||
| 67 | 0 | ▶ | { | ||||||||
|
Subroutine
to_number: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 68 | 0 | require HTML::Object::Number; | |||||||||
| 69 | 0 | return( HTML::Object::Number->new( shift->value ) ); | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | sub value { return( shift->SUPER::as_string ); } | ||||||||
|
Subroutine
value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 73 | |||||||||||
| 74 | 0 | ▶ | sub value_as_number { return( shift->as_number ); } | ||||||||
|
Subroutine
value_as_number: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 75 | |||||||||||
| 76 | 13 | 1; | |||||||||
| 77 | # NOTE: POD | ||||||||||
| 78 | __END__ | ||||||||||