The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::Object::Boolean

ABSTRACT

Boolean Class for Perl 5

SYNOPSIS

  package main;

  use Data::Object::Boolean;

  my $bool = Data::Object::Boolean->new; # false

DESCRIPTION

This package provides functions and representation for boolean values.

INHERITS

This package inherits behaviors from:

Data::Object::Kind

LIBRARIES

This package uses type constraints from:

Data::Object::Types

FUNCTIONS

This package implements the following functions:

false

  False() : Object

The False method returns a boolean object representing false.

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

isfalse

  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.

IsFalse example #1
  Data::Object::Boolean::IsFalse(); # true
IsFalse example #2
  Data::Object::Boolean::IsFalse(0); # true
IsFalse example #3
  Data::Object::Boolean::IsFalse(1); # false

istrue

  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.

IsTrue example #1
  Data::Object::Boolean::IsTrue(); # false
IsTrue example #2
  Data::Object::Boolean::IsTrue(1); # true
IsTrue example #3
  Data::Object::Boolean::IsTrue(0); # false

to_json

  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.

TO_JSON example #1
  my $bool = Data::Object::Boolean->new(1);

  $bool->TO_JSON; # \1
TO_JSON example #2
  Data::Object::Boolean::TO_JSON(
    Data::Object::Boolean::True()
  );

  # \1
TO_JSON example #3
  my $bool = Data::Object::Boolean->new(0);

  $bool->TO_JSON(0); # \0
TO_JSON example #4
  Data::Object::Boolean::TO_JSON(
    Data::Object::Boolean::False()
  );

  # \0

true

  True() : Object

The True method returns a boolean object representing truth.

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

type

  Type() : Str

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

Type example #1
  Data::Object::Boolean::Type(); # False
Type example #2
  Data::Object::Boolean::Type(1); # True
Type example #3
  Data::Object::Boolean::Type(0); # False
Type example #4
  Data::Object::Boolean::Type(
    Data::Object::Boolean::True()
  );

  # True
Type example #5
  Data::Object::Boolean::Type(
    Data::Object::Boolean::False()
  );

  # False

METHODS

This package implements the following methods:

new

  new(Maybe[Any] $arg) : Object

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

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

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 in the "license file".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues