Fink::Base(3) Fink documentation Fink::Base(3)NAMEFink::Base - basic parameter handling
SYNOPSIS
package My::Fink;
require Fink::Base;
@ISA = qw(Fink::Base);
my $obj = My::Fink->new_from_properties({ key1 => val1, ...});
my $val = $obj->param($param);
$obj->set_param($param, $val);
DESCRIPTION
Basic parameter handling for fink objects.
Constructors
new
my $obj = Fink::Base->new;
my $obj = Fink::Base->new @args;
Create a new, empty fink object, and initialize it with the given
arguments.
new_from_properties
my $obj = Fink::Base->new_from_properties({ key1 => val1, ...});
my $obj = Fink::Base->new_from_properties({ key1 => val1, ...}, @parameters);
Create a new fink object setting its parameters to the given hash,
and initialize it with the given arguments.
Any key with a leading _ is ignored.
initialize
$obj->initialize;
$obj->initialize(@parameters);
Protected method, do not call directly.
All Fink::Base constructors will call initialize() just before
returning the object.
The default initialize() is empty. You may override.
Parameter queries
All keys are used case insensitively.
param
my $value = $obj->param($param);
my $value = $obj->param($param, $default);
Returns the $value of the given $param. If $param is not set,
$default is returned (including 'undef' if no $default is given).
set_param
$obj->set_param($param, $value);
Sets the $param to $value. If $value is undef or '' the $param is
deleted.
param_default
my $value = $obj->param_default($param, $default_value);
Like param() but if the $param does not exist as a parameter
$default_value will be used.
param_boolean
my $value = $obj->param_boolean($param);
my $value = $obj->param_boolean($param, $default);
Interprets the value of $param as a boolean. "True", "Yes", "On"
and "1" are all considered true while all other values are
considered false. Returns 1 for true, 0 for false. If $param is not
set, $default is returned (including 'undef' if no $default is
given). The $default is returned exactly as passed, not converted
to 1/0 boolean value, so the return is tri-state
true/false/not-set.
has_param
my $exists = $obj->has_param($param);
Returns a boolean indicating if the given $param is set.
params_matching
my @params = $obj->params_matching($regex);
my @params = $obj->params_matching($regex, $with_case);
Returns a list of the parameters that exist for $obj that match the
given pattern $regex. Each returned value is suitable for passing
to the other param* methods. The string $regex is a treated as a
perl regular expression (which will not be further interpolated),
with the exception that it will not return parameters of which only
a substring matches. In perl terms, a leading ^ and trailing $ are
applied. In human terms, passing 'a.' will not return parameters
such as 'apple' or 'cat'. If the optional $with_case is given and
is true, matching will be done with case-sensitivity. If $with_case
is false or not given, the matching will be case-insensitive (i.e.,
a /i modifier is applied). In either case, the values returned are
in their actual case. The values are not returned in any particular
order.
Fink 0.36.3.1 2013-12-30 Fink::Base(3)