lib/HTML/Object/Literal.pm

filter: Statementstmt 51.2% 21 / 41 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 35.0% 7 / 20 Podpod 100% 13 / 13 totaltotal 53.9% 41 / 76 CC 2 SCAR 7.2
CC
2
Cov
49%
to_boolean
6.0
as_number
2.0
as_string
2.0
CRAP 2.0
« lib/HTML/Object/DOM/Window.pm ↑ Summary lib/HTML/Object/DOM/ValidityState.pm »
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 {
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' );
Subroutine BEGIN: called CC=1 SCAR=0.0
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 {
32 0 ▶ my $self = shift( @_ );
Subroutine as_string: not called CC=1 SCAR=6.9
Pod documented
33 0 my $txt = $self->SUPER::as_string;
34 # $txt =~ s/'/&apos;/g;
35 0 $txt =~ s/(?<!\\)\'/\\\'/g;
36 0 return( "'$txt'" );
37 }
38  
39 sub as_xml
40 {
41 0 ▶ my $self = shift( @_ );
Subroutine as_xml: not called CC=1 SCAR=6.9
Pod documented
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 {
59 0 ▶ require HTML::Object::Boolean;
Subroutine to_boolean: not called CC=2 SCAR=17.9
Pod documented
60 0 ▶ return( shift->as_string ? HTML::Object::Boolean->True : HTML::Object::Boolean->False );
Branch: 1 branch
BranchTrueFalseTotal
(shift())->as_string ? : 0 0 0
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 {
68 0 ▶ require HTML::Object::Number;
Subroutine to_number: not called CC=1 SCAR=6.9
Pod documented
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__
« lib/HTML/Object/DOM/Window.pm ↑ Summary lib/HTML/Object/DOM/ValidityState.pm »