NAME
HTML::Object::Boolean - HTML Object Boolean Class
SYNOPSIS
use HTML::Object::Boolean;
my $true = HTML::Object::Boolean->True;
my $false = HTML::Object::Boolean->False;
print $true->value; # 1
print $false->string_value; # false
print $true->to_literal; # true
VERSION
v0.2.0
DESCRIPTION
This module implements simple boolean true/false value objects for use within the HTML::Object framework, notably by the XPath and XQuery subsystems.
It inherits from Module::Generic::Boolean and adds DOM- and XPath-oriented coercion methods so that boolean values can be converted to literals, numbers, or string representations in a uniform way.
The object itself is a blessed scalar reference. "value" dereferences it and returns the raw Perl value: 1 for true, 0 for false.
METHODS
head2 False
my $false = HTML::Object::Boolean->False;
# or
my $false = $bool->False;
Returns a new HTML::Object::Boolean object whose value is false (0).
This method can be called on the class or on an existing instance; in both cases it always returns a new object.
See also "false" in Module::Generic::Boolean.
True
my $true = HTML::Object::Boolean->True;
# or
my $true = $bool->True;
Returns a new HTML::Object::Boolean object whose value is true (1).
This method can be called on the class or on an existing instance; in both cases it always returns a new object.
See also "true" in Module::Generic::Boolean.
getAttributes
my $attrs = $bool->getAttributes;
Returns an empty array object. Boolean values carry no attributes in the DOM model.
getChildNodes
my $children = $bool->getChildNodes;
Returns an empty array object. Boolean values are leaf nodes and have no children in the DOM model.
False
Creates a new Boolean object with a false value.
string_value
my $str = $bool->string_value; # 'true' or 'false'
Returns the string representation of the boolean value: true if the value is true, false otherwise. This is a plain Perl string, not an object.
Internally this delegates to "to_literal" and then calls value on the resulting HTML::Object::Literal object.
to_boolean
my $same = $bool->to_boolean;
Returns the current object unchanged. This method exists for interface uniformity with other XPath value types (HTML::Object::Literal, HTML::Object::Number) which must each implement to_boolean.
to_literal
my $literal = $bool->to_literal;
Returns a new HTML::Object::Literal object whose string value is true if the boolean is true, or false otherwise.
to_number
my $num = $bool->to_number;
Returns a new HTML::Object::Number object constructed from the raw boolean value: 1 for true, 0 for false.
value
my $val = $bool->value; # 1 or 0
Returns the raw Perl scalar stored inside the object: 1 for true, 0 for false. The object is internally a blessed scalar reference, and this method dereferences it.
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
HTML::Object, HTML::Object::Attribute, HTML::Object::Boolean, HTML::Object::Closing, HTML::Object::Collection, HTML::Object::Comment, HTML::Object::Declaration, HTML::Object::Document, HTML::Object::Element, HTML::Object::Exception, HTML::Object::Literal, HTML::Object::Number, HTML::Object::Root, HTML::Object::Space, HTML::Object::Text, HTML::Object::XQuery
COPYRIGHT & LICENSE
Copyright (c) 2021 DEGUEST Pte. Ltd.
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.