Livery.pm

filter: Statementstmt 50.0% 12 / 24 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 25.0% 2 / 8 Podpod 100% 5 / 5 totaltotal 35.8% 19 / 53 CC 6 SCAR 30.1
CC
6
Cov
33%
record_use
42.0
intro_year
2.0
intro_month
2.0
CRAP 20.2
« Pak.pm ↑ Summary Pakset.pm »
1 package Games::Simutrans::Livery;
2  
3 # An abstraction of a Simutrans livery. Various objects (vehicles)
4 # have liveries in Extended. It is possible that other objects
5 # (stations, bridges, etc.) could have liveries in the future.
6  
7 1 ▶use Mojo::Base -base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Mojo::Collection;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ################
11 #
12 ################
13  
14 1 has 'name'; # Short name as used in a Simutrans dat file
15 1 has 'description'; # Unused as yet?
16 1 has 'intro'; # First observed introduction of this livery in the pakset
17 1 has 'retire'; # and last retirement (both as year*12+month)
18 0 ▶has 'objects' => sub { Mojo::Collection->new() }; # names of objects in pakset using this livery
Subroutine __ANON__: not called CC=1 SCAR=1.2
19  
20 0 ▶sub record_use ($self, $obj) {
Subroutine record_use: not called CC=6 SCAR=37.4
Pod documented
21 # As a pakset is scanned, we record that this object (the
22 # instance, not just the name of it) uses this livery.
23  
24 0 ▶ return if $obj->{is_permanent};
Branch: 1 branch
BranchTrueFalseTotal
if $obj->{"is_permanent"} 0 0 0
25  
26 0 my $name = $obj->name;
27  
28 0 ▶ $self->intro($obj->intro) if (!defined $self->intro) || ($self->intro > $obj->intro); # find earliest
Branch: 1 branch
BranchTrueFalseTotal
if not defined $self->intro or $self->intro > $obj->intro 0 0 0
Condition0%0/3
not defined $self->intro or $self->intro > $obj->intro
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->intro or $self->intro > $obj->intro
not defined $self->intro $self->intro > $obj->intro
Truth table0%0/3
not(A) or B
A= not defined $self->introB= $self->intro > $obj->intro
ABresult
1X1
011
000
29 0 ▶ $self->retire($obj->retire) if (!defined $self->retire) || ($self->retire < $obj->retire); # find last
Branch: 1 branch
BranchTrueFalseTotal
if not defined $self->retire or $self->retire < $obj->retire 0 0 0
Condition0%0/3
not defined $self->retire or $self->retire < $obj->retire
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->retire or $self->retire < $obj->retire
not defined $self->retire $self->retire < $obj->retire
Truth table0%0/3
not(A) or B
A= not defined $self->retireB= $self->retire < $obj->retire
ABresult
1X1
011
000
30  
31 0 push @{$self->objects}, $obj->name;
32 0 $self->objects($self->objects->uniq);
33 }
34  
35 0 ▶sub intro_year ($self) { return $self->intro / 12; }
Subroutine intro_year: not called CC=1 SCAR=6.9
Pod documented
36 0 ▶sub intro_month ($self) { return $self->intro % 12 + 1; }
Subroutine intro_month: not called CC=1 SCAR=6.9
Pod documented
37 0 ▶sub retire_year ($self) { return $self->retire / 12; }
Subroutine retire_year: not called CC=1 SCAR=6.9
Pod documented
38 0 ▶sub retire_month ($self) { return $self->retire % 12 + 1; }
Subroutine retire_month: not called CC=1 SCAR=6.9
Pod documented
39  
40 1 1;
41  
42 __END__
« Pak.pm ↑ Summary Pakset.pm »