| 1 | package Lego::Part::Image; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # Pragmas. | ||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # Modules. | ||||||||||||||||||||||||||||
| 8 | 17 | ▶ | use Class::Utils qw(set_params); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 17 | ▶ | use Error::Pure qw(err); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 17 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 17 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # Constants. | ||||||||||||||||||||||||||||
| 14 | 17 | Readonly::Scalar our $EMPTY_STR => q{}; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # Version. | ||||||||||||||||||||||||||||
| 17 | 17 | our $VERSION = 0.05; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # Constructor. | ||||||||||||||||||||||||||||
| 20 | sub new { | ||||||||||||||||||||||||||||
| 21 | 33 | ▶ | my ($class, @params) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # Create object. | ||||||||||||||||||||||||||||
| 24 | 33 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # Part object. | ||||||||||||||||||||||||||||
| 27 | 33 | $self->{'part'} = undef; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # Process parameters. | ||||||||||||||||||||||||||||
| 30 | 33 | set_params($self, @params); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # Check part object. | ||||||||||||||||||||||||||||
| 33 | 25 | ▶ | if (! defined $self->{'part'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 4 | err "Parameter 'part' is required."; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 21 | ▶ | if (! blessed($self->{'part'}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($self->{"part"}) and $self->{"part"}->isa("Lego::Part")
MC/DC100%2/2
builtin::blessed($self->{"part"}) and $self->{"part"}->isa("Lego::Part")
builtin::blessed($self->{"part"})
$self->{"part"}->isa("Lego::Part")
Truth table100%3/3
A and B
A= builtin::blessed($self->{"part"})B= $self->{"part"}->isa("Lego::Part")
| |||||||||||||||||||||||||||||
| 37 | || ! $self->{'part'}->isa('Lego::Part')) { | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 8 | err "Parameter 'part' must be Lego::Part object."; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # Object. | ||||||||||||||||||||||||||||
| 43 | 13 | return $self; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # Get image. | ||||||||||||||||||||||||||||
| 47 | sub image { | ||||||||||||||||||||||||||||
| 48 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
image: called CC=1 SCAR=0.4
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | # TODO Implement getting of image with cache. | ||||||||||||||||||||||||||||
| 50 | 1 | err "This is abstract class. image() method not implemented."; | |||||||||||||||||||||||||||
| 51 | 0 | return; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # Get image URL. | ||||||||||||||||||||||||||||
| 55 | sub image_url { | ||||||||||||||||||||||||||||
| 56 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
image_url: called CC=1 SCAR=0.4
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 1 | err "This is abstract class. image_url() method not implemented."; | |||||||||||||||||||||||||||
| 58 | 0 | return; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 17 | 1; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||