blib/lib/BalanceOfPower/Relations/Treaty.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 50 CC 4 SCAR 23.0
CC
4
Cov
0%
short_tag
20.0
dump
2.0
load
2.0
CRAP 10.0
1 package BalanceOfPower::Relations::Treaty;
2 $BalanceOfPower::Relations::Treaty::VERSION = '0.300010';
3 use strict;
4 use v5.10;
5  
6 use Moo;
7  
8 with 'BalanceOfPower::Relations::Role::Relation';
9  
10 has type => (
11 is => 'ro',
12 );
13  
14 around 'print' => sub {
15 my $orig = shift;
16 my $self = shift;
17 return $self->short_tag . ": " .
18 $self->$orig();
19 };
20  
21 sub short_tag
22 {
23 my $self = shift;
24 if($self->type eq 'alliance')
25 {
26 return 'ALL';
27 }
28 elsif($self->type eq 'no aggression')
29 {
30 return 'NAG';
31 }
32 elsif($self->type eq 'commercial')
33 {
34 return 'COM';
35 }
36 else
37 {
38 return '???';
39 }
40  
41 }
42 sub dump
43 {
44 my $self = shift;
45 my $io = shift;
46 my $indent = shift || "";
47 print {$io} $indent . join(";", $self->node1, $self->node2, $self->type) . "\n";
48 }
49 sub load
50 {
51 my $self = shift;
52 my $data = shift;
53 $data =~ s/^\s+//;
54 chomp $data;
55 my ($node1, $node2, $type) = split ";", $data;
56 return $self->new(node1 => $node1, node2 => $node2, type => $type);
57 }
58  
59 1;