lib/HTML/Object/Space.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 100% 5 / 5 totaltotal 92.9% 53 / 57 CC 3 SCAR 3.1
CC
3
Cov
92%
as_string
2.0
init
2.0
as_xml
2.0
CRAP 1.4
« lib/HTML/Object/Text.pm ↑ Summary lib/HTML/Object/Closing.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/Space.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/04/19
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::Space;
15 BEGIN
16 {
17 33 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 33 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 33 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 33 ▶ use parent qw( HTML::Object::Element );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 33 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 33 our $VERSION = 'v0.2.0';
23 };
24  
25 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 sub init
29 {
30 482 ▶ my $self = shift( @_ );
Subroutine init: called CC=2 SCAR=7.0
Pod documented
31 482 $self->{is_empty} = 1;
32 482 $self->{tag} = '_space';
33 482 $self->{value} = undef;
34 482 $self->{_init_strict_use_sub} = 1;
35 482 $self->{_exception_class} = 'HTML::Object::Exception';
36 482 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 482 482
37 482 return( $self );
38 }
39  
40 sub as_string
41 {
42 151 ▶ my $self = shift( @_ );
Subroutine as_string: called CC=2 SCAR=7.1
Pod documented
43 # We need to remove the reset flag, otherwise if there are any subsequent change that need to be propagated to this space parent, HTML::Object::Element::reset will not propagate it
44 151 $self->_remove_reset;
45 151 ▶ return( $self->value->length ? $self->value : $self->original );
Branch: 1 branch
BranchTrueFalseTotal
$self->value->length ? : 151 0 151
46 }
47  
48 0 ▶sub as_xml { return( shift->as_string( @_ ) ); }
Subroutine as_xml: not called CC=1 SCAR=6.9
Pod documented
49  
50 sub set_checksum
51 {
52 482 ▶ my $self = shift( @_ );
Subroutine set_checksum: called CC=1 SCAR=0.0
Pod documented
53 482 return( $self->_get_md5_hash( $self->value->scalar ) );
54 }
55  
56 1514 ▶sub value : lvalue { return( shift->_set_get_scalar_as_object( 'value', @_ ) ); }
Subroutine value: called CC=1 SCAR=0.0
Pod documented
57 # {
58 # my $self = shift( @_ );
59 # if( @_ )
60 # {
61 # return( $self->_set_get_scalar_as_object( 'value', @_ ) );
62 # }
63 # my $val = $self->_set_get_scalar_as_object( 'value' );
64 # return( $val ) if( defined( $val ) && $val->defined );
65 # return( $self->original );
66 # }
67  
68 33 1;
69 # NOTE: POD
70 __END__
71  
72 =encoding utf-8
73  
74 =head1 NAME
75  
76 HTML::Object::Space - HTML Object
77  
78 =head1 SYNOPSIS
79  
80 use HTML::Object::Space;
81 my $sp = HTML::Object::Space->new ||
82 die( HTML::Object::Space->error, "\n" );
83  
84 =head1 VERSION
85  
86 v0.2.0
87  
88 =head1 DESCRIPTION
89  
90 This module represents or or more spaces. It is used to capture spaces between L<HTML elements|HTML::Object::Element>
91  
92 =head1 INHERITANCE
93  
94 +-----------------------+ +---------------------+
95 | HTML::Object::Element | --> | HTML::Object::Space |
96 +-----------------------+ +---------------------+
97  
98 =head1 PROPERTIES
99  
100 =head2 nodeValue
101  
102 This returns or sets the value of the current node.
103  
104 For document, element or collection, this returns C<undef> and for attribute, text or comment, this returns the objct value.
105  
106 See L<for more information|https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeValue>
107  
108 =head1 METHODS
109  
110 =head2 as_string
111  
112 Returns the space value enclosed.
113  
114 =head2 as_xml
115  
116 This is an alias for L</as_string>
117  
118 =head2 isEqualNode
119  
120 Returns a boolean value which indicates whether or not two elements are of the same type and all their defining data points match.
121  
122 Two elements are equal when they have the same type, defining characteristics (this would be their ID, number of children, and so forth), its attributes match, and so on. The specific set of data points that must match varies depending on the types of the elements.
123  
124 See L<for more information|https://developer.mozilla.org/en-US/docs/Web/API/Node/isEqualNode>
125  
126 =head2 nodeValue
127  
128 This returns or sets the value of the current element.
129  
130 See L<for more information|https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeValue>
131  
132 =head2 set_checksum
133  
134 Read-only method.
135  
136 This returns the md5 checksum for the current value.
137  
138 =head2 value
139  
140 Returns the current value as a L<scalar object|Module::Generic::Scalar>
141  
142 =head1 AUTHOR
143  
144 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
145  
146 =head1 SEE ALSO
147  
148 L<HTML::Object>, L<HTML::Object::Attribute>, L<HTML::Object::Boolean>, L<HTML::Object::Closing>, L<HTML::Object::Collection>, L<HTML::Object::Comment>, L<HTML::Object::Declaration>, L<HTML::Object::Document>, L<HTML::Object::Element>, L<HTML::Object::Exception>, L<HTML::Object::Literal>, L<HTML::Object::Number>, L<HTML::Object::Root>, L<HTML::Object::Space>, L<HTML::Object::Text>, L<HTML::Object::XQuery>
149  
150 =head1 COPYRIGHT & LICENSE
151  
152 Copyright (c) 2021 DEGUEST Pte. Ltd.
153  
154 All rights reserved
155  
156 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
157  
158 =cut
« lib/HTML/Object/Text.pm ↑ Summary lib/HTML/Object/Closing.pm »