NAME

PNI::Node - is a basic unit of code

SYNOPSIS

use PNI;

my $node = PNI::node 'Foo::Bar';


# Or use a scenario.

my $scenario = PNI::root->new_scenario;
my $node = $scenario->new_node( type => 'Foo::Bar' );


# Or do it yourself (:

use PNI::Node;

my $empty_node = PNI::Node->new;

# Decorate node.
my $in = $empty_node->in('lead');
my $out = $empty_node->out('gold');

# Fill input data.
$in->data('1Kg');

# Produce something.
$node->task;

# Get output data.
my $gold = $out->data;

ATTRIBUTES

box

ins

outs

METHODS

get_ins_edges

get_outs_edges

in

Creates an input by the given name if such input does not exists.

$node->in('input_name');

Returns a PNI::In object.

my $in = $node->in('input_name');

Default input name is 'in', so you are really lazy you can do

$node->in->data(1);

say $node->in->data;

If you pass number x as input_name, it will be replaced by inx.

$node->in(1);
$node->in('in1'); # ditto

is_on

$node->task if $node->is_on;

off

Turn off a node if something is wrong.

sub task {
    my $self = shift;

    # if "in" is not defined, return and turn off the node.
    $self->in->is_defined or return $self->off;
}

on

label

out

Creates an output by the given name if such output does not exists.

$node->out('output_name');

Returns a PNI::Out object.

my $out = $node->out('output_name');

Default output name is 'out', so you are really lazy you can do

$node->out->data(1)

say $node->out->data;

If you pass number x as output_name, it will be replaced by outx.

$node->out(1);
$node->out('out1'); # ditto

parents

Returns the list of nodes which outputs are connected to the node inputs.

task

translate

type