NAME
Lego::Part::Action - Lego part action object.
SYNOPSIS
use Lego::Part::Action;
my $obj = Lego::Part::Action->new;
$obj->load_design_id($part_transfer_class, $part);
$obj->load_element_id($part_transfer_class, $part);
METHODS
new()
Constructor. Returns object.
load_design_id($part_transfer_class, $part)
Load design id to Lego::Part object. Returns undef.
load_element_id($part_transfer_class, $part)
Load element id to Lego::Part object. Returns undef.
ERRORS
load_design_id():
Bad transfer class. Must be 'Lego::Part::Transfer' class.
Cannot load design ID.
Error: %s
load_element_id():
Bad transfer class. Must be 'Lego::Part::Transfer' class.
Cannot load element ID.
Error: %s
EXAMPLE
package Lego::Part::Transfer::Example;
use base qw(Lego::Part::Transfer);
use strict;
use warnings;
# Convert design to element.
sub design2element {
my ($self, $part) = @_;
$self->_check_part($part);
if ($part->color eq 'red' && $part->design_id eq '3002') {
$part->element_id('300221');
}
return;
}
package main;
use strict;
use warnings;
use Lego::Part;
use Lego::Part::Action;
# Lego part.
my $part = Lego::Part->new(
'color' => 'red',
'design_id' => '3002',
);
# Lego part action.
my $act = Lego::Part::Action->new;
# Transfer class.
my $trans = Lego::Part::Transfer::Example->new;
# Load element id.
$act->load_element_id($trans, $part);
# Print color and design ID.
print 'Color: '.$part->color."\n";
print 'Design ID: '.$part->design_id."\n";
print 'Element ID: '.$part->element_id."\n";
# Output:
# Color: red
# Design ID: 3002
# Element ID: 300221
DEPENDENCIES
Class::Utils, English, Error::Pure, Scalar::Util.
SEE ALSO
- Task::Lego
-
Install the Lego modules.
REPOSITORY
https://github.com/michal-josef-spacek/Lego-Part
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2013-2023 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.04