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: get method: into method: last method: list method: move 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 operting on lists of arguments.

Venus::Kind::Utility

The all method selects all arguments for processing returns the invocant.

all() (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(Str $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::Type method, and returns results.

cast(Str $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(Str @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(Str @pairs) (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() (Unpack)

{ since => '2.01', }

=example-1 first

# given: synopsis

package main;

$unpack = $unpack->first;

# bless(..., 'Venus::Unpack')

The get method returns the argument at the index specified.

get(Str $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(Str @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() (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(Str | 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(Str @pairs) (Unpack)

{ since => '2.01', }

=example-1 move

# given: synopsis

package main;

$unpack = $unpack->move(0 => 'arg1');

# bless({..., arg1 => 'hello'}, 'Venus::Unpack')

The one method returns the first result of the dispatched method call.

one(Str | 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) (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(Str $index, Any $value) (Any)

{ since => '2.01', }

=example-1 set

# given: synopsis

package main;

my $set = $unpack->set;

# undef

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(Str $name, Str @types) (ArrayRef)

{ since => '2.01', }

=example-1 signature

# given: synopsis

package main;

my ($string, $number, $float) = $unpack->all->signature(
  'example-1',
  '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(Str @types) (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(Int @args) (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(Str @types) (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: pdml: authors t/Venus.t: pdml: license

106 POD Errors

The following errors were encountered while parsing the POD:

Around line 13:

Unknown directive: =name

Around line 21:

Unknown directive: =tagline

Around line 29:

Unknown directive: =abstract

Around line 37:

Unknown directive: =includes

Around line 64:

Unknown directive: =synopsis

Around line 89:

Unknown directive: =description

Around line 98:

Unknown directive: =inherits

Around line 106:

Unknown directive: =method

Around line 110:

Unknown directive: =signature

Around line 114:

Unknown directive: =metadata

Around line 141:

Unknown directive: =method

Around line 145:

Unknown directive: =signature

Around line 149:

Unknown directive: =metadata

Around line 185:

=cut found outside a pod block. Skipping to next block.

Around line 205:

=cut found outside a pod block. Skipping to next block.

Around line 215:

Unknown directive: =method

Around line 220:

Unknown directive: =signature

Around line 224:

Unknown directive: =metadata

Around line 260:

=cut found outside a pod block. Skipping to next block.

Around line 270:

Unknown directive: =method

Around line 274:

Unknown directive: =signature

Around line 278:

Unknown directive: =metadata

Around line 306:

Unknown directive: =method

Around line 311:

Unknown directive: =signature

Around line 315:

Unknown directive: =metadata

Around line 364:

=cut found outside a pod block. Skipping to next block.

Around line 379:

Unknown directive: =method

Around line 385:

Unknown directive: =signature

Around line 389:

Unknown directive: =metadata

Around line 425:

=cut found outside a pod block. Skipping to next block.

Around line 445:

=cut found outside a pod block. Skipping to next block.

Around line 465:

=cut found outside a pod block. Skipping to next block.

Around line 485:

=cut found outside a pod block. Skipping to next block.

Around line 495:

Unknown directive: =method

Around line 500:

Unknown directive: =signature

Around line 504:

Unknown directive: =metadata

Around line 544:

=cut found outside a pod block. Skipping to next block.

Around line 568:

=cut found outside a pod block. Skipping to next block.

Around line 582:

Unknown directive: =method

Around line 587:

Unknown directive: =signature

Around line 591:

Unknown directive: =metadata

Around line 618:

Unknown directive: =method

Around line 622:

Unknown directive: =signature

Around line 626:

Unknown directive: =metadata

Around line 662:

=cut found outside a pod block. Skipping to next block.

Around line 682:

=cut found outside a pod block. Skipping to next block.

Around line 702:

=cut found outside a pod block. Skipping to next block.

Around line 722:

=cut found outside a pod block. Skipping to next block.

Around line 732:

Unknown directive: =method

Around line 737:

Unknown directive: =signature

Around line 741:

Unknown directive: =metadata

Around line 790:

=cut found outside a pod block. Skipping to next block.

Around line 819:

=cut found outside a pod block. Skipping to next block.

Around line 834:

Unknown directive: =method

Around line 839:

Unknown directive: =signature

Around line 843:

Unknown directive: =metadata

Around line 870:

Unknown directive: =method

Around line 875:

Unknown directive: =signature

Around line 879:

Unknown directive: =metadata

Around line 926:

=cut found outside a pod block. Skipping to next block.

Around line 951:

=cut found outside a pod block. Skipping to next block.

Around line 979:

=cut found outside a pod block. Skipping to next block.

Around line 992:

Unknown directive: =method

Around line 997:

Unknown directive: =signature

Around line 1001:

Unknown directive: =metadata

Around line 1041:

=cut found outside a pod block. Skipping to next block.

Around line 1065:

=cut found outside a pod block. Skipping to next block.

Around line 1079:

Unknown directive: =method

Around line 1083:

Unknown directive: =signature

Around line 1087:

Unknown directive: =metadata

Around line 1128:

=cut found outside a pod block. Skipping to next block.

Around line 1139:

Unknown directive: =method

Around line 1144:

Unknown directive: =signature

Around line 1148:

Unknown directive: =metadata

Around line 1186:

=cut found outside a pod block. Skipping to next block.

Around line 1198:

Unknown directive: =method

Around line 1203:

Unknown directive: =signature

Around line 1207:

Unknown directive: =metadata

Around line 1243:

=cut found outside a pod block. Skipping to next block.

Around line 1263:

=cut found outside a pod block. Skipping to next block.

Around line 1283:

=cut found outside a pod block. Skipping to next block.

Around line 1303:

=cut found outside a pod block. Skipping to next block.

Around line 1313:

Unknown directive: =method

Around line 1320:

Unknown directive: =signature

Around line 1324:

Unknown directive: =metadata

Around line 1366:

=cut found outside a pod block. Skipping to next block.

Around line 1389:

=cut found outside a pod block. Skipping to next block.

Around line 1414:

=cut found outside a pod block. Skipping to next block.

Around line 1426:

Unknown directive: =method

Around line 1432:

Unknown directive: =signature

Around line 1436:

Unknown directive: =metadata

Around line 1472:

=cut found outside a pod block. Skipping to next block.

Around line 1494:

=cut found outside a pod block. Skipping to next block.

Around line 1517:

=cut found outside a pod block. Skipping to next block.

Around line 1528:

Unknown directive: =method

Around line 1533:

Unknown directive: =signature

Around line 1537:

Unknown directive: =metadata

Around line 1573:

=cut found outside a pod block. Skipping to next block.

Around line 1593:

=cut found outside a pod block. Skipping to next block.

Around line 1603:

Unknown directive: =method

Around line 1609:

Unknown directive: =signature

Around line 1613:

Unknown directive: =metadata

Around line 1649:

=cut found outside a pod block. Skipping to next block.

Around line 1669:

=cut found outside a pod block. Skipping to next block.

Around line 1690:

=cut found outside a pod block. Skipping to next block.

Around line 1701:

Unknown directive: =partials