NAME

Venus::Vars - Vars Class

ABSTRACT

Vars Class for Perl 5

SYNOPSIS

package main;

use Venus::Vars;

my $vars = Venus::Vars->new(
  value => { USER => 'awncorp', HOME => '/home/awncorp', },
  named => { iam => 'USER', root => 'HOME', },
);

# $vars->root; # $ENV{HOME}
# $vars->home; # $ENV{HOME}
# $vars->get('home'); # $ENV{HOME}
# $vars->get('HOME'); # $ENV{HOME}

# $vars->iam; # $ENV{USER}
# $vars->user; # $ENV{USER}
# $vars->get('user'); # $ENV{USER}
# $vars->get('USER'); # $ENV{USER}

DESCRIPTION

This package provides methods for accessing %ENV items.

ATTRIBUTES

This package has the following attributes:

named

named(HashRef)

This attribute is read-write, accepts (HashRef) values, is optional, and defaults to {}.

INHERITS

This package inherits behaviors from:

Venus::Kind::Utility

INTEGRATES

This package integrates behaviors from:

Venus::Role::Accessible

Venus::Role::Buildable

Venus::Role::Proxyable

Venus::Role::Valuable

METHODS

This package provides the following methods:

default

default() (hashref)

The default method returns the default value, i.e. {%ENV}.

Since 0.01

default example 1
# given: synopsis;

my $default = $vars->default;

# { USER => 'awncorp', HOME => '/home/awncorp', ... }

exists

exists(string $key) (boolean)

The exists method takes a name or index and returns truthy if an associated value exists.

Since 0.01

exists example 1
# given: synopsis;

my $exists = $vars->exists('iam');;

# 1
exists example 2
# given: synopsis;

my $exists = $vars->exists('USER');;

# 1
exists example 3
# given: synopsis;

my $exists = $vars->exists('PATH');

# undef
exists example 4
# given: synopsis;

my $exists = $vars->exists('user');

# 1

get

get(string $key) (any)

The get method takes a name or index and returns the associated value.

Since 0.01

get example 1
# given: synopsis;

my $get = $vars->get('iam');

# "awncorp"
get example 2
# given: synopsis;

my $get = $vars->get('USER');

# "awncorp"
get example 3
# given: synopsis;

my $get = $vars->get('PATH');

# undef
get example 4
# given: synopsis;

my $get = $vars->get('user');

# "awncorp"

name

name(string $key) (string | undef)

The name method takes a name or index and returns index if the the associated value exists.

Since 0.01

name example 1
# given: synopsis;

my $name = $vars->name('iam');

# "USER"
name example 2
# given: synopsis;

my $name = $vars->name('USER');

# "USER"
name example 3
# given: synopsis;

my $name = $vars->name('PATH');

# undef
name example 4
# given: synopsis;

my $name = $vars->name('user');

# "USER"

set

set(string $key, any $value) (any)

The set method takes a name or index and sets the value provided if the associated argument exists.

Since 0.01

set example 1
# given: synopsis;

my $set = $vars->set('iam', 'root');

# "root"
set example 2
# given: synopsis;

my $set = $vars->set('USER', 'root');

# "root"
set example 3
# given: synopsis;

my $set = $vars->set('PATH', '/tmp');

# undef
set example 4
# given: synopsis;

my $set = $vars->set('user', 'root');

# "root"

unnamed

unnamed() (hashref)

The unnamed method returns an arrayref of values which have not been named using the named attribute.

Since 0.01

unnamed example 1
package main;

use Venus::Vars;

my $vars = Venus::Vars->new(
  value => { USER => 'awncorp', HOME => '/home/awncorp', },
  named => { root => 'HOME', },
);

my $unnamed = $vars->unnamed;

# { USER => "awncorp" }

AUTHORS

Awncorp, awncorp@cpan.org

LICENSE

Copyright (C) 2000, Awncorp, awncorp@cpan.org.

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.