File Coverage

lib/HTML/Object/Space.pm
Criterion Covered Total %
statement 36 37 97.3
branch 2 4 50.0
condition n/a
subroutine 12 13 92.3
pod 5 5 100.0
total 55 59 93.2


line stmt bran cond sub pod time code
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 29     29   198 use strict;
  29         50  
  29         931  
18 29     29   191 use warnings;
  29         62  
  29         748  
19 29     29   143 use warnings::register;
  29         52  
  29         2859  
20 29     29   159 use parent qw( HTML::Object::Element );
  29         52  
  29         143  
21 29     29   1845 use vars qw( $VERSION );
  29         55  
  29         1230  
22 29     29   581 our $VERSION = 'v0.2.0';
23             };
24              
25 29     29   136 use strict;
  29         47  
  29         540  
26 29     29   113 use warnings;
  29         50  
  29         6114  
27              
28             sub init
29             {
30 370     370 1 3869 my $self = shift( @_ );
31 370         1351 $self->{is_empty} = 1;
32 370         1245 $self->{tag} = '_space';
33 370         999 $self->{value} = undef;
34 370         889 $self->{_init_strict_use_sub} = 1;
35 370         997 $self->{_exception_class} = 'HTML::Object::Exception';
36 370 50       2123 $self->SUPER::init( @_ ) || return( $self->pass_error );
37 370         2635 return( $self );
38             }
39              
40             sub as_string
41             {
42 38     38 1 114 my $self = shift( @_ );
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 38         209 $self->_remove_reset;
45 38 50       163 return( $self->value->length ? $self->value : $self->original );
46             }
47              
48 0     0 1 0 sub as_xml { return( shift->as_string( @_ ) ); }
49              
50             sub set_checksum
51             {
52 370     370 1 1426 my $self = shift( @_ );
53 370         1715 return( $self->_get_md5_hash( $self->value->scalar ) );
54             }
55              
56 816     816 1 7930200 sub value : lvalue { return( shift->_set_get_scalar_as_object( 'value', @_ ) ); }
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             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