| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/XPath/Variable.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::Variable; | ||||||||||
| 15 | BEGIN | ||||||||||
| 16 | { | ||||||||||
| 17 | 12 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 12 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 12 | ▶ | warnings::register_categories( 'HTML::Object' ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 12 | ▶ | use parent qw( Module::Generic ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 12 | ▶ | use vars qw( $DEBUG $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 12 | our $DEBUG = 0; | |||||||||
| 23 | 12 | our $VERSION = 'v0.2.0'; | |||||||||
| 24 | }; | ||||||||||
| 25 | |||||||||||
| 26 | 12 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 12 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | sub init | ||||||||||
| 30 | { | ||||||||||
| 31 | 0 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 32 | 0 | $self->{path_parser} = shift( @_ ); | |||||||||
| 33 | 0 | $self->{name} = shift( @_ ); | |||||||||
| 34 | 0 | $self->{_init_strict_use_sub} = 1; | |||||||||
| 35 | 0 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | return( $self ); | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | sub as_string | ||||||||||
| 40 | { | ||||||||||
| 41 | 0 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | 0 | return( '\$' . $self->{name} ); | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | sub as_xml | ||||||||||
| 46 | { | ||||||||||
| 47 | 0 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
as_xml: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | 0 | return( "<Variable>" . $self->{name} . "</Variable>\n" ); | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | sub get_value | ||||||||||
| 52 | { | ||||||||||
| 53 | 0 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
get_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 54 | 0 | return( $self->{path_parser}->get_var( $self->{name} ) ); | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | sub set_value | ||||||||||
| 58 | { | ||||||||||
| 59 | 0 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
set_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 60 | 0 | my $val = shift( @_ ); | |||||||||
| 61 | 0 | return( $self->{path_parser}->set_var( $self->{name} => $val ) ); | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | sub evaluate | ||||||||||
| 65 | { | ||||||||||
| 66 | 0 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 67 | 0 | my $val = $self->get_value; | |||||||||
| 68 | 0 | return( $val ); | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 12 | 1; | |||||||||
| 72 | # NOTE: POD | ||||||||||
| 73 | __END__ | ||||||||||
| 74 | |||||||||||
| 75 | =encoding utf-8 | ||||||||||
| 76 | |||||||||||
| 77 | =head1 NAME | ||||||||||
| 78 | |||||||||||
| 79 | HTML::Object::XPath::Variable - HTML Object XPath Variable | ||||||||||
| 80 | |||||||||||
| 81 | =head1 SYNOPSIS | ||||||||||
| 82 | |||||||||||
| 83 | use HTML::Object::XPath::Variable; | ||||||||||
| 84 | my $var = HTML::Object::XPath::Variable->new || | ||||||||||
| 85 | die( HTML::Object::XPath::Variable->error, "\n" ); | ||||||||||
| 86 | |||||||||||
| 87 | =head1 VERSION | ||||||||||
| 88 | |||||||||||
| 89 | v0.2.0 | ||||||||||
| 90 | |||||||||||
| 91 | =head1 DESCRIPTION | ||||||||||
| 92 | |||||||||||
| 93 | This represent a L<HTML::Object::XPath> variable | ||||||||||
| 94 | |||||||||||
| 95 | =head1 CONSTRUCTOR | ||||||||||
| 96 | |||||||||||
| 97 | =head2 new | ||||||||||
| 98 | |||||||||||
| 99 | Provided with a L<HTML::Object::XPath> object and a variable name and this return a new l<HTML::Object::XPath::Variable> object. | ||||||||||
| 100 | |||||||||||
| 101 | =head1 METHODS | ||||||||||
| 102 | |||||||||||
| 103 | =head2 as_string | ||||||||||
| 104 | |||||||||||
| 105 | Returns a string representation of the variable. | ||||||||||
| 106 | |||||||||||
| 107 | =head2 as_xml | ||||||||||
| 108 | |||||||||||
| 109 | Returns a xml representation of the variable. | ||||||||||
| 110 | |||||||||||
| 111 | =head2 get_value | ||||||||||
| 112 | |||||||||||
| 113 | Returns the value for the variable set upon object instantiation. This actually calls L<HTML::Object::XPath/get_var> | ||||||||||
| 114 | |||||||||||
| 115 | =head2 set_value | ||||||||||
| 116 | |||||||||||
| 117 | Set the value for the variable set upon object instantiation. This actually calls L<HTML::Object::XPath/set_var> | ||||||||||
| 118 | |||||||||||
| 119 | =head2 evaluate | ||||||||||
| 120 | |||||||||||
| 121 | Returns the variable value by returning L</get_value> | ||||||||||
| 122 | |||||||||||
| 123 | =head1 AUTHOR | ||||||||||
| 124 | |||||||||||
| 125 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||||||||||
| 126 | |||||||||||
| 127 | =head1 SEE ALSO | ||||||||||
| 128 | |||||||||||
| 129 | 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> | ||||||||||
| 130 | |||||||||||
| 131 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 132 | |||||||||||
| 133 | Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||
| 134 | |||||||||||
| 135 | All rights reserved | ||||||||||
| 136 | |||||||||||
| 137 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 138 | |||||||||||
| 139 | =cut | ||||||||||