line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## CSS Object Oriented - ~/lib/CSS/Object/Selector.pm |
3
|
|
|
|
|
|
|
## Version v0.1.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2020 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <@sitael.local> |
6
|
|
|
|
|
|
|
## Created 2020/06/21 |
7
|
|
|
|
|
|
|
## Modified 2020/06/21 |
8
|
|
|
|
|
|
|
## |
9
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
package CSS::Object::Selector; |
11
|
|
|
|
|
|
|
BEGIN |
12
|
|
|
|
|
|
|
{ |
13
|
6
|
|
|
6
|
|
46
|
use strict; |
|
6
|
|
|
|
|
30
|
|
|
6
|
|
|
|
|
232
|
|
14
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
192
|
|
15
|
6
|
|
|
6
|
|
32
|
use parent qw( CSS::Object::Element ); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
36
|
|
16
|
6
|
|
|
6
|
|
407
|
use Devel::Confess; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
50
|
|
17
|
6
|
|
|
6
|
|
1600
|
our $VERSION = 'v0.1.0'; |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub init |
21
|
|
|
|
|
|
|
{ |
22
|
48
|
|
|
48
|
1
|
5857
|
my $self = shift( @_ ); |
23
|
48
|
|
|
|
|
426
|
$self->{name} = ''; |
24
|
48
|
|
|
|
|
121
|
$self->{format} = ''; |
25
|
48
|
|
|
|
|
129
|
$self->{_init_strict_use_sub} = 1; |
26
|
48
|
|
|
|
|
276
|
$self->SUPER::init( @_ ); |
27
|
48
|
|
|
|
|
133
|
return( $self ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
## Inherited |
31
|
|
|
|
|
|
|
## sub format |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub add_to |
34
|
|
|
|
|
|
|
{ |
35
|
14
|
|
|
14
|
1
|
35
|
my $self = shift( @_ ); |
36
|
14
|
|
50
|
|
|
51
|
my $rule = shift( @_ ) || return( $self->error( "No rule object was provided to add our selctor to it." ) ); |
37
|
14
|
50
|
|
|
|
452
|
return( $self->error( "Rule object provided (", overload::StrVal( $rule ), ") is not actually a CSS::Object::Rule object." ) ) if( !$self->_is_a( $rule, 'CSS::Object::Rule' ) ); |
38
|
14
|
|
|
|
|
243
|
$self->format->indent( $rule->format->indent ); |
39
|
14
|
|
|
|
|
2497
|
$rule->add_selector( $self ); |
40
|
14
|
|
|
|
|
39
|
return( $self ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
1
|
0
|
sub as_string { return( shift->name ); } |
44
|
|
|
|
|
|
|
|
45
|
468
|
|
|
468
|
1
|
8325
|
sub name { return( shift->_set_get_scalar_as_object( 'name', @_ ) ); } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=encoding utf-8 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
CSS::Object::Selector - CSS Object Oriented Selector |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SYNOPSIS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use CSS::Object::Selector; |
60
|
|
|
|
|
|
|
my $sel = CSS::Object::Selector->new( |
61
|
|
|
|
|
|
|
name => $css_selector, |
62
|
|
|
|
|
|
|
debug => 3, |
63
|
|
|
|
|
|
|
format => $format_object |
64
|
|
|
|
|
|
|
) || die( CSS::Object::Selector->error ); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 VERSION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
v0.1.0 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L<CSS::Object::Selector> is a class to contain the name of a selector. For any given css rule, there can be multiple selectors. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Selector objects can be accessed with L<CSS::Object::Rule/selectors> which is an L<Module::Generic::Array> object. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 new |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
To instantiate a new L<CSS::Object::Selector> object, pass an hash reference of following parameters: |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over 4 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item I<debug> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This is an integer. The bigger it is and the more verbose is the output. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item I<format> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is a L<CSS::Object::Format> object or one of its child modules. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item I<name> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This is the selector's name. When provided, this calls the method L</name> to store the value. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 METHODS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 add_to |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Provided with a L<CSS::Object::Rule> object, and this will add our selector object to it by calling L<CSS::Object::Rule/add_selector> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
It returns our selector object to allow chaining. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 as_string |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This returns the selector's name. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Maybe, this should be changed to calling a method B<selector_as_string> in the L<CSS::Object::Format>, but the reasons for modifying a selector's name are limited. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 format |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This is a L<CSS::Object::Format> object or one of its child modules. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 name |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Sets or gets the selector's name. The name stored here becomes a L<Module::Generic::Scalar> and thus all its object methods can be used |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SEE ALSO |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
L<CSS::Object> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Copyright (c) 2020 DEGUEST Pte. Ltd. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
133
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |