NAME
Venus::Type - Type Class
ABSTRACT
Type Class for Perl 5
SYNOPSIS
package main;
use Venus::Type;
my $type = Venus::Type->new([]);
# $type->code;
DESCRIPTION
This package provides methods for casting native data types to objects and the reverse.
INHERITS
This package inherits behaviors from:
INTEGRATES
This package integrates behaviors from:
METHODS
This package provides the following methods:
code
code() (Str | Undef)
The code method returns the name of the value's data type.
Since 0.01
- code example 2
-
package main; use Venus::Type; my $type = Venus::Type->new(value => {}); my $code = $type->code; # "HASH"
- code example 3
-
package main; use Venus::Type; my $type = Venus::Type->new(value => qr//); my $code = $type->code; # "REGEXP"
deduce
deduce() (Object)
The deduce methods returns the argument as a data type object.
Since 0.01
- deduce example 1
-
# given: synopsis; my $deduce = $type->deduce; # bless({ value => [] }, "Venus::Array")
- deduce example 2
-
package main; use Venus::Type; my $type = Venus::Type->new(value => {}); my $deduce = $type->deduce; # bless({ value => {} }, "Venus::Hash")
- deduce example 3
-
package main; use Venus::Type; my $type = Venus::Type->new(value => qr//); my $deduce = $type->deduce; # bless({ value => qr// }, "Venus::Regexp")
- deduce example 4
-
package main; use Venus::Type; my $type = Venus::Type->new(value => '1.23'); my $deduce = $type->deduce; # bless({ value => "1.23" }, "Venus::Float")
deduce_deep
deduce_deep() (Object)
The deduce_deep function returns any arguments as data type objects, including nested data.
Since 0.01
- deduce_deep example 1
-
package main; use Venus::Type; my $type = Venus::Type->new(value => [1..4]); my $deduce_deep = $type->deduce_deep; # bless({ # value => [ # bless({ value => 1 }, "Venus::Number"), # bless({ value => 2 }, "Venus::Number"), # bless({ value => 3 }, "Venus::Number"), # bless({ value => 4 }, "Venus::Number"), # ], # }, "Venus::Array")
- deduce_deep example 2
-
package main; use Venus::Type; my $type = Venus::Type->new(value => {1..4}); my $deduce_deep = $type->deduce_deep; # bless({ # value => { # 1 => bless({ value => 2 }, "Venus::Number"), # 3 => bless({ value => 4 }, "Venus::Number"), # }, # }, "Venus::Hash")
detract
detract() (Any)
The detract method returns the argument as native Perl data type value.
Since 0.01
- detract example 1
-
package main; use Venus::Type; use Venus::Hash; my $type = Venus::Type->new(Venus::Hash->new({1..4})); my $detract = $type->detract; # { 1 => 2, 3 => 4 }
- detract example 2
-
package main; use Venus::Type; use Venus::Array; my $type = Venus::Type->new(Venus::Array->new([1..4])); my $detract = $type->detract; # [1..4]
- detract example 3
-
package main; use Venus::Type; use Venus::Regexp; my $type = Venus::Type->new(Venus::Regexp->new(qr/\w+/)); my $detract = $type->detract; # qr/\w+/
- detract example 4
-
package main; use Venus::Type; use Venus::Float; my $type = Venus::Type->new(Venus::Float->new('1.23')); my $detract = $type->detract; # "1.23"
detract_deep
detract_deep() (Any)
The detract_deep method returns any arguments as native Perl data type values, including nested data.
Since 0.01
- detract_deep example 1
-
package main; use Venus::Type; use Venus::Hash; my $type = Venus::Type->new(Venus::Hash->new({1..4})); my $detract_deep = Venus::Type->new($type->deduce_deep)->detract_deep; # { 1 => 2, 3 => 4 }
- detract_deep example 2
-
package main; use Venus::Type; use Venus::Array; my $type = Venus::Type->new(Venus::Array->new([1..4])); my $detract_deep = Venus::Type->new($type->deduce_deep)->detract_deep; # [1..4]
package
package() (Str)
The code method returns the package name of the objectified value, i.e. ref()
.
Since 0.01
- package example 2
-
package main; use Venus::Type; my $type = Venus::Type->new(value => {}); my $package = $type->package; # "Venus::Hash"
AUTHORS
Cpanery, cpanery@cpan.org
LICENSE
Copyright (C) 2021, Cpanery
Read the "license" file.