| 1 | package Lego::Part::Action; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # Pragmas. | ||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # Modules. | ||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Class::Utils qw(set_params); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use English; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Error::Pure qw(err); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # Version. | ||||||||||||||||||||||||||||
| 14 | 2 | our $VERSION = 0.03; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # Constructor. | ||||||||||||||||||||||||||||
| 17 | sub new { | ||||||||||||||||||||||||||||
| 18 | 0 | ▶ | my ($class, @params) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # Create object. | ||||||||||||||||||||||||||||
| 21 | 0 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # Process parameters. | ||||||||||||||||||||||||||||
| 24 | 0 | set_params($self, @params); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # Object. | ||||||||||||||||||||||||||||
| 27 | 0 | return $self; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | # Load design id to Lego::Part object. | ||||||||||||||||||||||||||||
| 31 | sub load_design_id { | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my ($self, $part_transfer_class, $part) = @_; | ||||||||||||||||||||||||||
|
Subroutine
load_design_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 0 | $self->_check_part_transfer_class($part_transfer_class); | |||||||||||||||||||||||||||
| 34 | 0 | eval { | |||||||||||||||||||||||||||
| 35 | 0 | $part_transfer_class->element2design($part); | |||||||||||||||||||||||||||
| 36 | }; | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ($EVAL_ERROR) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 0 | err 'Cannot load design ID.', | |||||||||||||||||||||||||||
| 39 | 'Error', $EVAL_ERROR; | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 0 | return; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # Load element id to Lego::Part object. | ||||||||||||||||||||||||||||
| 45 | sub load_element_id { | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my ($self, $part_transfer_class, $part) = @_; | ||||||||||||||||||||||||||
|
Subroutine
load_element_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | 0 | $self->_check_part_transfer_class($part_transfer_class); | |||||||||||||||||||||||||||
| 48 | 0 | eval { | |||||||||||||||||||||||||||
| 49 | 0 | $part_transfer_class->design2element($part); | |||||||||||||||||||||||||||
| 50 | }; | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($EVAL_ERROR) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | err 'Cannot load element ID.', | |||||||||||||||||||||||||||
| 53 | 'Error', $EVAL_ERROR; | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 0 | return; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | # Check transfer class. | ||||||||||||||||||||||||||||
| 59 | sub _check_part_transfer_class { | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my ($self, $part_transfer_class) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_check_part_transfer_class: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if (! blessed($part_transfer_class) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($part_transfer_class) and $part_transfer_class->isa("Lego::Part::Transfer")
MC/DC0%0/2
builtin::blessed($part_transfer_class) and $part_transfer_class->isa("Lego::Part::Transfer")
builtin::blessed($part_transfer_class)
$part_transfer_class->isa("Lego::Part::Transfer")
Truth table0%0/3
A and B
A= builtin::blessed($part_transfer_class)B= $part_transfer_class->isa("Lego::Part::Transfer")
| |||||||||||||||||||||||||||||
| 62 | || ! $part_transfer_class->isa('Lego::Part::Transfer')) { | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | err "Bad transfer class. Must be 'Lego::Part::Transfer' ". | |||||||||||||||||||||||||||
| 65 | 'class.'; | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | 0 | return; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 2 | 1; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | __END__ | ||||||||||||||||||||||||||||