Venus::Unpack
Unpack Class
Unpack Class for Perl 5
method: all method: arg method: args method: array method: cast method: checks method: copy method: first method: from method: get method: into method: last method: list method: move method: name method: new method: one method: reset method: set method: signature method: types method: use method: validate
package main;
use Venus::Unpack;
my $unpack = Venus::Unpack->new(args => ["hello", 123, 1.23]);
# my $args = $unpack->all->types('string', 'number', 'float')->args;
# ["hello", 123, 1.23]
This package provides methods for validating, coercing, and otherwise operating on lists of arguments.
Venus::Kind::Utility
The all method selects all arguments for processing returns the invocant.
all() (Venus::Unpack)
{ since => '2.01', }
=example-1 all
# given: synopsis
package main;
$unpack = $unpack->all;
# bless(..., 'Venus::Unpack')
The arg method returns the argument at the index specified.
arg(string $index) (any)
{ since => '2.01', }
=example-1 arg
# given: synopsis
package main;
my $arg = $unpack->arg(0);
# "hello"
The args method returns all arugments as an arrayref, or list in list context. If arguments are provided they will overwrite the existing arugment list.
args(any @args) (arrayref)
{ since => '2.01', }
=example-1 args
# given: synopsis
package main;
my $args = $unpack->args;
# ["hello", 123, 1.23]
The array method returns the argument list as a Venus::Array object.
array() (Venus::Array)
{ since => '2.01', }
=example-1 array
# given: synopsis
package main;
my $array = $unpack->array;
# bless(..., 'Venus::Array')
The cast method processes the selected arguments, passing each value to the class name specified, or the "cast" in Venus::What method, and returns results.
cast(string $name) (arrayref)
{ since => '2.01', }
=example-1 cast
# given: synopsis
package main;
my $cast = $unpack->all->cast;
# [
# bless(..., 'Venus::String'),
# bless(..., 'Venus::Number'),
# bless(..., 'Venus::Float'),
# ]
The checks method processes the selected arguments, passing each value to the "check" in Venus::Assert method with the type expression provided, and returns results.
checks(string @types) (arrayref)
{ since => '2.01', }
=example-1 checks
# given: synopsis
package main;
my $checks = $unpack->all->checks('string');
# [true, false, false]
The copy method copies values from the arugment list as properties of the underlying object and returns the invocant.
copy(string @pairs) (Venus::Unpack)
{ since => '2.01', }
=example-1 copy
# given: synopsis
package main;
$unpack = $unpack->copy(0 => 'arg1');
# bless({..., arg1 => 'hello'}, 'Venus::Unpack')
The first method selects the first argument for processing returns the invocant.
first() (Venus::Unpack)
{ since => '2.01', }
=example-1 first
# given: synopsis
package main;
$unpack = $unpack->first;
# bless(..., 'Venus::Unpack')
The from method names the source of the unpacking operation and is used in exception messages whenever the "signature" in Venus::Unpack operation fails. This method returns the invocant.
from(string $data) (Venus::Unpack)
{ since => '2.23', }
=example-1 from
# given: synopsis
package main;
$unpack = $unpack->from;
# bless(..., 'Venus::Unpack')
The get method returns the argument at the index specified.
get(string $index) (any)
{ since => '2.01', }
=example-1 get
# given: synopsis
package main;
my $get = $unpack->get;
# undef
The into method processes the selected arguments, passing each value to the class name specified, and returns results.
into(string @args) (any)
{ since => '2.01', }
=example-1 into
# given: synopsis
package main;
my $cast = $unpack->all->into('Venus::String');
# [
# bless(..., 'Venus::String'),
# bless(..., 'Venus::String'),
# bless(..., 'Venus::String'),
# ]
The last method selects the last argument for processing returns the invocant.
last() (Venus::Unpack)
{ since => '2.01', }
=example-1 last
# given: synopsis
package main;
$unpack = $unpack->last;
# bless(..., 'Venus::Unpack')
The list method returns the result of the dispatched method call as an arrayref, or list in list context.
list(string | coderef $code, any @args) (arrayref)
{ since => '2.01', }
=example-1 list
# given: synopsis
package main;
my (@args) = $unpack->all->list('cast');
# (
# bless(..., 'Venus::String'),
# bless(..., 'Venus::Number'),
# bless(..., 'Venus::Float'),
# )
The move method moves values from the arugment list, reducing the arugment list, as properties of the underlying object and returns the invocant.
move(string @pairs) (Venus::Unpack)
{ since => '2.01', }
=example-1 move
# given: synopsis
package main;
$unpack = $unpack->move(0 => 'arg1');
# bless({..., arg1 => 'hello'}, 'Venus::Unpack')
The name method names the unpacking operation and is used in exception messages whenever the "signature" in Venus::Unpack operation fails. This method returns the invocant.
name(string $data) (Venus::Unpack)
{ since => '2.23', }
=example-1 name
# given: synopsis
package main;
$unpack = $unpack->name;
# bless(..., 'Venus::Unpack')
The new method constructs an instance of the package.
new(any @args) (Venus::Unpack)
{ since => '4.15', }
The one method returns the first result of the dispatched method call.
one(string | coderef $code, any @args) (any)
{ since => '2.01', }
=example-1 one
# given: synopsis
package main;
my $one = $unpack->all->one('cast');
# (
# bless(..., 'Venus::String'),
# )
The reset method resets the arugments list (if provided) and deselects all arguments (selected for processing) and returns the invocant.
reset(any @args) (Venus::Unpack)
{ since => '2.01', }
=example-1 reset
# given: synopsis
package main;
$unpack = $unpack->all->reset;
# bless(..., 'Venus::Unpack')
The set method assigns the value provided at the index specified and returns the value.
set(string $index, any $value) (any)
{ since => '2.01', }
=example-1 set
# given: synopsis
package main;
my $set = $unpack->set;
# ["hello", 123, 1.23]
The signature method processes the selected arguments, passing each value to the "validate" in Venus::Assert method with the type expression provided and throws an exception on failure and otherise returns the results as an arrayref, or as a list in list context.
signature(string $name, string @types) (arrayref)
{ since => '2.01', }
=example-1 signature
# given: synopsis
package main;
my ($string, $number, $float) = $unpack->all->name('example-1')->signature(
'string | number | float',
);
# ("hello", 123, 1.23)
The types method processes the selected arguments, passing each value to the "validate" in Venus::Assert method with the type expression provided, and unlike the "validate" method returns the invocant.
types(string @types) (Venus::Unpack)
{ since => '2.01', }
=example-1 types
# given: synopsis
package main;
$unpack = $unpack->all->types('string | number | float');
# bless({...}, 'Venus::Unpack')
The use method selects the arguments specified (by index) for processing returns the invocant.
use(number @args) (Venus::Unpack)
{ since => '2.01', }
=example-1 use
# given: synopsis
package main;
$unpack = $unpack->use(1,2);
# bless(..., 'Venus::Unpack')
The validate method processes the selected arguments, passing each value to the "validate" in Venus::Assert method with the type expression provided and throws an exception on failure and otherise returns the resuts.
validate(string @types) (Venus::Unpack)
{ since => '2.01', }
=example-1 validate
# given: synopsis
package main;
my $results = $unpack->all->validate('string | number | float');
# ["hello", 123, 1.23]
t/Venus.t: present: authors t/Venus.t: present: license
120 POD Errors
The following errors were encountered while parsing the POD:
- Around line 14:
Unknown directive: =name
- Around line 22:
Unknown directive: =tagline
- Around line 30:
Unknown directive: =abstract
- Around line 38:
Unknown directive: =includes
- Around line 68:
Unknown directive: =synopsis
- Around line 93:
Unknown directive: =description
- Around line 102:
Unknown directive: =inherits
- Around line 110:
Unknown directive: =method
- Around line 114:
Unknown directive: =signature
- Around line 118:
Unknown directive: =metadata
- Around line 145:
Unknown directive: =method
- Around line 149:
Unknown directive: =signature
- Around line 153:
Unknown directive: =metadata
- Around line 189:
=cut found outside a pod block. Skipping to next block.
- Around line 209:
=cut found outside a pod block. Skipping to next block.
- Around line 219:
Unknown directive: =method
- Around line 224:
Unknown directive: =signature
- Around line 228:
Unknown directive: =metadata
- Around line 264:
=cut found outside a pod block. Skipping to next block.
- Around line 274:
Unknown directive: =method
- Around line 278:
Unknown directive: =signature
- Around line 282:
Unknown directive: =metadata
- Around line 310:
Unknown directive: =method
- Around line 315:
Unknown directive: =signature
- Around line 319:
Unknown directive: =metadata
- Around line 368:
=cut found outside a pod block. Skipping to next block.
- Around line 383:
Unknown directive: =method
- Around line 389:
Unknown directive: =signature
- Around line 393:
Unknown directive: =metadata
- Around line 429:
=cut found outside a pod block. Skipping to next block.
- Around line 449:
=cut found outside a pod block. Skipping to next block.
- Around line 469:
=cut found outside a pod block. Skipping to next block.
- Around line 489:
=cut found outside a pod block. Skipping to next block.
- Around line 499:
Unknown directive: =method
- Around line 504:
Unknown directive: =signature
- Around line 508:
Unknown directive: =metadata
- Around line 548:
=cut found outside a pod block. Skipping to next block.
- Around line 572:
=cut found outside a pod block. Skipping to next block.
- Around line 586:
Unknown directive: =method
- Around line 591:
Unknown directive: =signature
- Around line 595:
Unknown directive: =metadata
- Around line 622:
Unknown directive: =method
- Around line 628:
Unknown directive: =signature
- Around line 632:
Unknown directive: =metadata
- Around line 669:
=cut found outside a pod block. Skipping to next block.
- Around line 680:
Unknown directive: =method
- Around line 684:
Unknown directive: =signature
- Around line 688:
Unknown directive: =metadata
- Around line 724:
=cut found outside a pod block. Skipping to next block.
- Around line 744:
=cut found outside a pod block. Skipping to next block.
- Around line 764:
=cut found outside a pod block. Skipping to next block.
- Around line 784:
=cut found outside a pod block. Skipping to next block.
- Around line 794:
Unknown directive: =method
- Around line 799:
Unknown directive: =signature
- Around line 803:
Unknown directive: =metadata
- Around line 852:
=cut found outside a pod block. Skipping to next block.
- Around line 881:
=cut found outside a pod block. Skipping to next block.
- Around line 896:
Unknown directive: =method
- Around line 901:
Unknown directive: =signature
- Around line 905:
Unknown directive: =metadata
- Around line 932:
Unknown directive: =method
- Around line 937:
Unknown directive: =signature
- Around line 941:
Unknown directive: =metadata
- Around line 988:
=cut found outside a pod block. Skipping to next block.
- Around line 1013:
=cut found outside a pod block. Skipping to next block.
- Around line 1041:
=cut found outside a pod block. Skipping to next block.
- Around line 1054:
Unknown directive: =method
- Around line 1059:
Unknown directive: =signature
- Around line 1063:
Unknown directive: =metadata
- Around line 1103:
=cut found outside a pod block. Skipping to next block.
- Around line 1127:
=cut found outside a pod block. Skipping to next block.
- Around line 1141:
Unknown directive: =method
- Around line 1147:
Unknown directive: =signature
- Around line 1151:
Unknown directive: =metadata
- Around line 1188:
=cut found outside a pod block. Skipping to next block.
- Around line 1199:
Unknown directive: =method
- Around line 1203:
Unknown directive: =signature
- Around line 1207:
Unknown directive: =metadata
- Around line 1225:
=cut found outside a pod block. Skipping to next block.
- Around line 1245:
=cut found outside a pod block. Skipping to next block.
- Around line 1256:
Unknown directive: =method
- Around line 1260:
Unknown directive: =signature
- Around line 1264:
Unknown directive: =metadata
- Around line 1305:
=cut found outside a pod block. Skipping to next block.
- Around line 1316:
Unknown directive: =method
- Around line 1321:
Unknown directive: =signature
- Around line 1325:
Unknown directive: =metadata
- Around line 1363:
=cut found outside a pod block. Skipping to next block.
- Around line 1375:
Unknown directive: =method
- Around line 1380:
Unknown directive: =signature
- Around line 1384:
Unknown directive: =metadata
- Around line 1420:
=cut found outside a pod block. Skipping to next block.
- Around line 1440:
=cut found outside a pod block. Skipping to next block.
- Around line 1460:
=cut found outside a pod block. Skipping to next block.
- Around line 1480:
=cut found outside a pod block. Skipping to next block.
- Around line 1490:
Unknown directive: =method
- Around line 1497:
Unknown directive: =signature
- Around line 1501:
Unknown directive: =metadata
- Around line 1541:
=cut found outside a pod block. Skipping to next block.
- Around line 1563:
=cut found outside a pod block. Skipping to next block.
- Around line 1586:
=cut found outside a pod block. Skipping to next block.
- Around line 1609:
=cut found outside a pod block. Skipping to next block.
- Around line 1620:
Unknown directive: =method
- Around line 1626:
Unknown directive: =signature
- Around line 1630:
Unknown directive: =metadata
- Around line 1666:
=cut found outside a pod block. Skipping to next block.
- Around line 1688:
=cut found outside a pod block. Skipping to next block.
- Around line 1711:
=cut found outside a pod block. Skipping to next block.
- Around line 1722:
Unknown directive: =method
- Around line 1727:
Unknown directive: =signature
- Around line 1731:
Unknown directive: =metadata
- Around line 1767:
=cut found outside a pod block. Skipping to next block.
- Around line 1787:
=cut found outside a pod block. Skipping to next block.
- Around line 1797:
Unknown directive: =method
- Around line 1803:
Unknown directive: =signature
- Around line 1807:
Unknown directive: =metadata
- Around line 1843:
=cut found outside a pod block. Skipping to next block.
- Around line 1863:
=cut found outside a pod block. Skipping to next block.
- Around line 1884:
=cut found outside a pod block. Skipping to next block.
- Around line 1895:
Unknown directive: =partials