| 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 | 14 | ▶ | { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 14 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 14 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 14 | warnings::register_categories( 'HTML::Object' ); | |||||||||||||||||||
| 20 | 14 | ▶ | use vars qw( $DEBUG $VERSION ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | 14 | ▶ | use overload ( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 14 | '""' => \&value, | |||||||||||||||||||
| 23 | '<=>' => \&cmp, | ||||||||||||||||||||
| 24 | 'bool' => \&value, | ||||||||||||||||||||
| 25 | fallback => 1, | ||||||||||||||||||||
| 26 | 14 | ); | |||||||||||||||||||
| 27 | 14 | our $DEBUG = 0; | |||||||||||||||||||
| 28 | 14 | our $VERSION = 'v0.2.0'; | |||||||||||||||||||
| 29 | }; | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 14 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 32 | 14 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | sub cmp | ||||||||||||||||||||
| 35 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
cmp: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 36 | 0 | my $self = shift( @_ ); | |||||||||||||||||||
| 37 | 0 | my( $other, $swap ) = @_; | |||||||||||||||||||
| 38 | 0 | ▶ | if( $swap ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | { | ||||||||||||||||||||
| 40 | 0 | return( $other <=> $$self ); | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | 0 | return( $$self <=> $other ); | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | sub False | ||||||||||||||||||||
| 46 | 70 | ▶ | { | ||||||||||||||||||
|
Subroutine
False: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 47 | 70 | my $this = shift( @_ ); | |||||||||||||||||||
| 48 | 70 | my $val = 0; | |||||||||||||||||||
| 49 | 70 | ▶ | return( bless( \$val => ( ref( $this ) || $this ) ) ); | ||||||||||||||||||
|
Condition33%1/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table33%1/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 0 | ▶ | sub getAttributes { return( wantarray() ? () : [] ); } | ||||||||||||||||||
|
Subroutine
getAttributes: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 0 | ▶ | sub getChildNodes { return( wantarray() ? () : [] ); } | ||||||||||||||||||
|
Subroutine
getChildNodes: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | ▶ | sub string_value { return( $_[0]->to_literal->value ); } | ||||||||||||||||||
|
Subroutine
string_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 20 | ▶ | sub to_boolean { return( $_[0] ); } | ||||||||||||||||||
|
Subroutine
to_boolean: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | sub to_literal | ||||||||||||||||||||
| 61 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
to_literal: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 62 | 0 | require HTML::Object::XPath::Literal; | |||||||||||||||||||
| 63 | 0 | ▶ | return( HTML::Object::XPath::Literal->new( $_[0]->value ? 'true' : 'false' ) ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | sub to_number | ||||||||||||||||||||
| 67 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
to_number: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 68 | 0 | require HTML::Object::XPath::Number; | |||||||||||||||||||
| 69 | 0 | return( HTML::Object::XPath::Number->new( $_[0]->value ) ); | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | sub True | ||||||||||||||||||||
| 73 | 70 | ▶ | { | ||||||||||||||||||
|
Subroutine
True: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 74 | 70 | my $this = shift( @_ ); | |||||||||||||||||||
| 75 | 70 | my $val = 1; | |||||||||||||||||||
| 76 | 70 | ▶ | return( bless( \$val => ( ref( $this ) || $this ) ) ); | ||||||||||||||||||
|
Condition33%1/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table33%1/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | sub value | ||||||||||||||||||||
| 80 | 529 | ▶ | { | ||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 81 | 529 | my $self = shift( @_ ); | |||||||||||||||||||
| 82 | 529 | return( $$self ); | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 14 | 1; | |||||||||||||||||||
| 86 | # NOTE: POD | ||||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||