File Coverage

lib/HTML/Object/Closing.pm
Criterion Covered Total %
statement 33 34 97.0
branch 3 4 75.0
condition n/a
subroutine 12 13 92.3
pod 5 5 100.0
total 53 56 94.6


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## HTML Object - ~/lib/HTML/Object/Closing.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::Closing;
15             BEGIN
16             {
17 29     29   218 use strict;
  29         64  
  29         1150  
18 29     29   155 use warnings;
  29         57  
  29         812  
19 29     29   176 use warnings::register;
  29         72  
  29         3993  
20 29     29   167 use parent qw( HTML::Object::Element );
  29         64  
  29         297  
21 29     29   2279 use vars qw( $VERSION );
  29         63  
  29         1923  
22 29     29   543 our $VERSION = 'v0.2.0';
23             };
24              
25 29     29   175 use strict;
  29         66  
  29         547  
26 29     29   159 use warnings;
  29         78  
  29         6089  
27              
28             sub init
29             {
30 263     263 1 2378 my $self = shift( @_ );
31 263         1220 $self->{is_empty} = 1;
32 263         1023 $self->{tag} = '_closing';
33 263         882 $self->{_init_strict_use_sub} = 1;
34 263         969 $self->{_exception_class} = 'HTML::Object::Exception';
35 263 50       1628 $self->SUPER::init( @_ ) || return( $self->pass_error );
36 263         1842 return( $self );
37             }
38              
39             sub as_string
40             {
41 89     89 1 225 my $self = shift( @_ );
42 89         372 my $tag = $self->tag;
43 89 100       83439 return( $self->original->length ? $self->original : $self->new_scalar( "</${tag}>" ) );
44             }
45              
46 0     0 1 0 sub as_xml { return( shift->as_string( @_ ) ); }
47              
48 263     263 1 819 sub checksum { return( '' ); }
49              
50       263 1   sub set_checksum {}
51              
52             1;
53             # NOTE: POD
54             __END__
55              
56             =encoding utf8
57              
58             =head1 NAME
59              
60             HTML::Object::Closing - HTML Object Closing Tag Class
61              
62             =head1 SYNOPSIS
63              
64             use HTML::Object::Closing;
65             my $close = HTML::Object::Closing->new(
66             tag => 'div',
67             );
68             # My opening div tag object
69             $elem->close_tag( $close );
70              
71             =head1 VERSION
72              
73             v0.2.0
74              
75             =head1 DESCRIPTION
76              
77             This module represents the end of a tag for tags that are not empty. Thos objects are in the dom by necessity, but are not used directly. They are always attached to the object of another L<HTML element|HTML::Object::Element>
78              
79             This module inherits from L<HTML::Object::Element>
80              
81             =head1 INHERITANCE
82              
83             +-----------------------+ +-----------------------+
84             | HTML::Object::Element | --> | HTML::Object::Closing |
85             +-----------------------+ +-----------------------+
86              
87             =head1 CONSTRUCTOR
88              
89             =head2 new
90              
91             Creates and returns a new tag closing object.
92              
93             Creates a new C<HTML::Object::Closing> objects.
94             It may also take an hash like arguments, that also are method of the same name.
95              
96             =head1 METHODS
97              
98             On top of the methods inherited from L<HTML::Object::Element>, this module implements also the following methods:
99              
100             =head2 as_string
101              
102             Returns a string version of this closing tag. Unless it was modified, it will return the version exactly the same as when it was parsed from some HTML data, if any.
103              
104             =head2 as_xml
105              
106             This is an alias for L</as_string>
107              
108             =head2 checksum
109              
110             Returns an empty string.
111              
112             =head2 set_checksum
113              
114             Does absolutely nothing and is here to prevent the inherited method from being triggered.
115              
116             =head1 AUTHOR
117              
118             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
119              
120             =head1 SEE ALSO
121              
122             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>
123              
124             =head1 COPYRIGHT & LICENSE
125              
126             Copyright (c) 2021 DEGUEST Pte. Ltd.
127              
128             All rights reserved
129              
130             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
131              
132             =cut