File Coverage

blib/lib/CSS/Object/Comment.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 2 100.0
condition 2 3 66.6
subroutine 8 8 100.0
pod 3 3 100.0
total 38 39 97.4


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## CSS Object Oriented - ~/lib/CSS/Object/Comment.pm
3             ## Version v0.2.0
4             ## Copyright(c) 2020 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2020/06/21
7             ## Modified 2024/09/05
8             ## All rights reserved
9             ##
10             ## This program is free software; you can redistribute it and/or modify it
11             ## under the same terms as Perl itself.
12             ##----------------------------------------------------------------------------
13             package CSS::Object::Comment;
14             BEGIN
15             {
16 6     6   39 use strict;
  6         13  
  6         279  
17 6     6   34 use warnings;
  6         12  
  6         338  
18 6     6   29 use parent qw( CSS::Object::Element );
  6         47  
  6         59  
19             use overload (
20 6         62 '""' => 'as_string',
21             fallback => 1,
22 6     6   611 );
  6         13  
23 6     6   1908 our $VERSION = 'v0.2.0';
24             };
25              
26             sub init
27             {
28 8     8 1 1060 my $self = shift( @_ );
29 8         20 my $this = shift( @_ );
30 8 100 66     81 if( CORE::length( $this ) && $self->_is_array( $this ) )
31             {
32 5         70 $self->values->push( @$this );
33             }
34             else
35             {
36 3         45 $self->values->push( $this );
37             }
38 8         8076 $self->SUPER::init( @_ );
39 8         35 return( $self );
40             }
41              
42             sub as_string
43             {
44 48     48 1 24140 my $self = shift( @_ );
45 48         191 return( $self->format->comment_as_string( $self ) );
46             }
47              
48 56     56 1 226 sub values { return( shift->_set_get_object_array_object( 'values', 'CSS::Object::Value', @_ ) ); }
49              
50             1;
51              
52             __END__
53              
54             =encoding utf-8
55              
56             =head1 NAME
57              
58             CSS::Object::Comment - CSS Object Oriented Comment
59              
60             =head1 SYNOPSIS
61              
62             use CSS::Object::Comment;
63             my $cmt = CSS::Object::Comment->new( "No comment" ) ||
64             die( CSS::Object::Comment->error );
65              
66             =head1 VERSION
67              
68             v0.2.0
69              
70             =head1 DESCRIPTION
71              
72             L<CSS::Object::Comment> represent a comment inside a style sheet.
73              
74             Comments can appear anywhere between rules or inside rules between properties.
75              
76             =head1 CONSTRUCTOR
77              
78             =head2 new
79              
80             It take either a string or an array reference of string representing comment data.
81              
82             It also takes the following optional arguments.
83              
84             =over 4
85              
86             =item I<debug>
87              
88             This is an integer. The bigger it is and the more verbose is the output.
89              
90             =item I<format>
91              
92             This is a L<CSS::Object::Format> object or one of its child modules.
93              
94             =back
95              
96             =head1 METHODS
97              
98             =head2 as_string
99              
100             This stringify the comment, formatting it propertly
101              
102             =head2 format
103              
104             This is a L<CSS::Object::Format> object or one of its child modules.
105              
106             =head2 values
107              
108             This sets or returns the array object containing the comment lines. This is a L<Module::Generic::Array> object.
109              
110             =head1 AUTHOR
111              
112             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
113              
114             =head1 SEE ALSO
115              
116             L<CSS::Object>
117              
118             =head1 COPYRIGHT & LICENSE
119              
120             Copyright (c) 2020 DEGUEST Pte. Ltd.
121              
122             You can use, copy, modify and redistribute this package and associated
123             files under the same terms as Perl itself.
124              
125             =cut