NAME

Data::Object::Boolean

ABSTRACT

Data-Object Boolean Class

SYNOPSIS

use Data::Object::Boolean;

my $bool;

$bool = Data::Object::Boolean->new; # false
$bool = Data::Object::Boolean->new(1); # true
$bool = Data::Object::Boolean->new(0); # false
$bool = Data::Object::Boolean->new(''); # false
$bool = Data::Object::Boolean->new(undef); # false

DESCRIPTION

This package provides functions and representation for boolean values.

FUNCTIONS

This package implements the following functions.

false

False() : Object

The False function returns a boolean object representing false.

False example
Data::Object::Boolean::False(); # false

isfalse

IsFalse(Maybe[Any] $arg) : Object

The IsFalse function returns a boolean object representing false if no arugments are passed, otherwise this function will return a boolean object based on the argument provided.

IsFalse example
Data::Object::Boolean::IsFalse(); # false
Data::Object::Boolean::IsFalse($value); # true/false

istrue

IsTrue() : Object

The IsTrue function returns a boolean object representing truth if no arugments are passed, otherwise this function will return a boolean object based on the argument provided.

IsTrue example
Data::Object::Boolean::IsTrue(); # true
Data::Object::Boolean::IsTrue($value); # true/false

to_json

TO_JSON(Any $arg) : Ref['SCALAR']

The TO_JSON function 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.

TO_JSON example
Data::Object::Boolean::TO_JSON($true); # \1
Data::Object::Boolean::TO_JSON($false); # \0

true

True() : Object

The True function returns a boolean object representing truth.

True example
Data::Object::Boolean::True(); # true

type

Type() : Object

The Type function returns either "True" or "False" based on the truthiness or falsiness of the argument provided.

Type example
Data::Object::Boolean::Type($value); # "True" or "False"

METHODS

This package implements the following methods.

new

new(Any $arg) : Object

The new method returns a boolean object based on the value of the argument provided.

new example
my $bool;

$bool = Data::Object::Boolean->new; # false
$bool = Data::Object::Boolean->new(1); # true
$bool = Data::Object::Boolean->new(0); # false
$bool = Data::Object::Boolean->new(''); # false
$bool = Data::Object::Boolean->new(undef); # false

CREDITS

Al Newkirk, +319

Anthony Brummett, +10

Adam Hopkins, +2

José Joaquín Atria, +1

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

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 here, https://github.com/iamalnewkirk/do/blob/master/LICENSE.

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues

SEE ALSO

To get the most out of this distribution, consider reading the following:

Do

Data::Object

Data::Object::Class

Data::Object::ClassHas

Data::Object::Role

Data::Object::RoleHas

Data::Object::Library