Data::Object::Boolean
Boolean Class for Perl 5
package main; use Data::Object::Boolean; my $bool = Data::Object::Boolean->new; # false
This package provides functions and representation for boolean values.
This package inherits behaviors from:
Data::Object::Kind
This package uses type constraints from:
Data::Object::Types
This package implements the following functions:
False() : Object
The False method returns a boolean object representing false.
Data::Object::Boolean::False(); # false
IsFalse(Maybe[Any] $arg) : Object
The IsFalse method returns a boolean object representing false if no arugments are passed, otherwise this function will return a boolean object based on the argument provided.
Data::Object::Boolean::IsFalse(); # true
Data::Object::Boolean::IsFalse(0); # true
Data::Object::Boolean::IsFalse(1); # false
IsTrue() : Object
The IsTrue method returns a boolean object representing truth if no arugments are passed, otherwise this function will return a boolean object based on the argument provided.
Data::Object::Boolean::IsTrue(); # false
Data::Object::Boolean::IsTrue(1); # true
Data::Object::Boolean::IsTrue(0); # false
TO_JSON(Any $arg) : Ref['SCALAR']
The TO_JSON method returns a scalar ref representing truthiness or falsiness based on the arguments passed, this function is commonly used by JSON encoders and instructs them on how they should represent the value.
my $bool = Data::Object::Boolean->new(1); $bool->TO_JSON; # \1
Data::Object::Boolean::TO_JSON( Data::Object::Boolean::True() ); # \1
my $bool = Data::Object::Boolean->new(0); $bool->TO_JSON(0); # \0
Data::Object::Boolean::TO_JSON( Data::Object::Boolean::False() ); # \0
True() : Object
The True method returns a boolean object representing truth.
Data::Object::Boolean::True(); # true
Type() : Str
The Type method returns either "True" or "False" based on the truthiness or falsiness of the argument provided.
Data::Object::Boolean::Type(); # False
Data::Object::Boolean::Type(1); # True
Data::Object::Boolean::Type(0); # False
Data::Object::Boolean::Type( Data::Object::Boolean::True() ); # True
Data::Object::Boolean::Type( Data::Object::Boolean::False() ); # False
This package implements the following methods:
new(Maybe[Any] $arg) : Object
The new method returns a boolean object based on the value of the argument provided.
my $bool = Data::Object::Boolean->new(1); # true
my $bool = Data::Object::Boolean->new(0); # false
my $bool = Data::Object::Boolean->new(''); # false
my $bool = Data::Object::Boolean->new(undef); # false
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install Data::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Object
CPAN shell
perl -MCPAN -e shell install Data::Object
For more information on module installation, please visit the detailed CPAN module installation guide.