line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## HTML Object - ~/lib/HTML/Object/XPath/Boolean.pm |
3
|
|
|
|
|
|
|
## Version v0.2.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2021 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2021/12/05 |
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::XPath::Boolean; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
8
|
|
|
8
|
|
83
|
use strict; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
238
|
|
18
|
8
|
|
|
8
|
|
46
|
use warnings; |
|
8
|
|
|
|
|
33
|
|
|
8
|
|
|
|
|
250
|
|
19
|
8
|
|
|
8
|
|
62
|
use vars qw( $DEBUG $VERSION ); |
|
8
|
|
|
|
|
28
|
|
|
8
|
|
|
|
|
614
|
|
20
|
|
|
|
|
|
|
use overload ( |
21
|
8
|
|
|
|
|
125
|
'""' => \&value, |
22
|
|
|
|
|
|
|
'<=>' => \&cmp |
23
|
8
|
|
|
8
|
|
79
|
); |
|
8
|
|
|
|
|
33
|
|
24
|
8
|
|
|
8
|
|
917
|
our $DEBUG = 0; |
25
|
8
|
|
|
|
|
186
|
our $VERSION = 'v0.2.0'; |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
8
|
|
|
8
|
|
55
|
use strict; |
|
8
|
|
|
|
|
22
|
|
|
8
|
|
|
|
|
170
|
|
29
|
8
|
|
|
8
|
|
48
|
use warnings; |
|
8
|
|
|
|
|
28
|
|
|
8
|
|
|
|
|
3168
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub cmp |
32
|
|
|
|
|
|
|
{ |
33
|
0
|
|
|
0
|
1
|
0
|
my $self = shift( @_ ); |
34
|
0
|
|
|
|
|
0
|
my( $other, $swap ) = @_; |
35
|
0
|
0
|
|
|
|
0
|
if( $swap ) |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
|
|
0
|
return( $other <=> $$self ); |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
0
|
return( $$self <=> $other ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub False |
43
|
|
|
|
|
|
|
{ |
44
|
40
|
|
|
40
|
1
|
79
|
my $this = shift( @_ ); |
45
|
40
|
|
|
|
|
52
|
my $val = 0; |
46
|
40
|
|
33
|
|
|
177
|
return( bless( \$val => ( ref( $this ) || $this ) ) ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
0
|
1
|
0
|
sub getAttributes { return( wantarray() ? () : [] ); } |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
0
|
1
|
0
|
sub getChildNodes { return( wantarray() ? () : [] ); } |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
0
|
1
|
0
|
sub string_value { return( $_[0]->to_literal->value ); } |
54
|
|
|
|
|
|
|
|
55
|
20
|
|
|
20
|
1
|
61
|
sub to_boolean { return( $_[0] ); } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub to_literal |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
0
|
1
|
0
|
require HTML::Object::XPath::Literal; |
60
|
0
|
0
|
|
|
|
0
|
return( HTML::Object::XPath::Literal->new( $_[0]->value ? 'true' : 'false' ) ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub to_number |
64
|
|
|
|
|
|
|
{ |
65
|
0
|
|
|
0
|
1
|
0
|
require HTML::Object::XPath::Number; |
66
|
0
|
|
|
|
|
0
|
return( HTML::Object::XPath::Number->new( $_[0]->value ) ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub True |
70
|
|
|
|
|
|
|
{ |
71
|
40
|
|
|
40
|
1
|
110
|
my $this = shift( @_ ); |
72
|
40
|
|
|
|
|
71
|
my $val = 1; |
73
|
40
|
|
33
|
|
|
262
|
return( bless( \$val => ( ref( $this ) || $this ) ) ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub value |
77
|
|
|
|
|
|
|
{ |
78
|
920
|
|
|
920
|
1
|
1262
|
my $self = shift( @_ ); |
79
|
920
|
|
|
|
|
3773
|
return( $$self ); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
# NOTE: POD |
84
|
|
|
|
|
|
|
__END__ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=encoding utf-8 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
HTML::Object::XPath::Boolean - HTML Object |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSIS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
use HTML::Object::XPath::Boolean; |
95
|
|
|
|
|
|
|
my $this = HTML::Object::XPath::Boolean->new || die( HTML::Object::XPath::Boolean->error, "\n" ); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 VERSION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
v0.2.0 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 DESCRIPTION |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This module implements simple boolean true/false objects. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 METHODS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 cmp |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This method is called for overloading the comparison operator. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
It takes another element and it returns true if the two elements are same or false otherwise. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 getAttributes |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Returns an empty list in list context and an empty array reference in scalar context. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 getChildNodes |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Returns an empty list in list context and an empty array reference in scalar context. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 string_value |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns the current value as a L<literal|HTML::Object::XPath::Literal> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 to_boolean |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Returns the current object. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 to_literal |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Returns C<true> if true, or C<false> otherwise, as a L<literal object|HTML::Object::XPath::Literal> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 to_number |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Returns the current value as a L<number object|HTML::Object::XPath::Number> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 True |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Creates a new Boolean object with a true value. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
HTML::Object::XPath::Boolean->True; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 False |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Creates a new Boolean object with a false value. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
HTML::Object::XPath::Boolean->False; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 value |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns true or false. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 AUTHOR |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 SEE ALSO |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L<HTML::Object::XPath>, L<HTML::Object::XPath::Boolean>, L<HTML::Object::XPath::Expr>, L<HTML::Object::XPath::Function>, L<HTML::Object::XPath::Literal>, L<HTML::Object::XPath::LocationPath>, L<HTML::Object::XPath::NodeSet>, L<HTML::Object::XPath::Number>, L<HTML::Object::XPath::Root>, L<HTML::Object::XPath::Step>, L<HTML::Object::XPath::Variable> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Copyright(c) 2021 DEGUEST Pte. Ltd. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
All rights reserved |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |