File Coverage

lib/BalanceOfPower/Relations/Treaty.pm
Criterion Covered Total %
statement 8 25 32.0
branch 0 6 0.0
condition 0 2 0.0
subroutine 3 6 50.0
pod 0 3 0.0
total 11 42 26.1


line stmt bran cond sub pod time code
1             package BalanceOfPower::Relations::Treaty;
2             $BalanceOfPower::Relations::Treaty::VERSION = '0.400110';
3 13     13   45 use strict;
  13         16  
  13         280  
4 13     13   94 use v5.10;
  13         30  
5              
6 13     13   39 use Moo;
  13         16  
  13         53  
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 0     0 0   my $self = shift;
24 0 0         if($self->type eq 'alliance')
    0          
    0          
25             {
26 0           return 'ALL';
27             }
28             elsif($self->type eq 'no aggression')
29             {
30 0           return 'NAG';
31             }
32             elsif($self->type eq 'commercial')
33             {
34 0           return 'COM';
35             }
36             else
37             {
38 0           return '???';
39             }
40              
41             }
42             sub dump
43             {
44 0     0 0   my $self = shift;
45 0           my $io = shift;
46 0   0       my $indent = shift || "";
47 0           print {$io} $indent . join(";", $self->node1, $self->node2, $self->type) . "\n";
  0            
48             }
49             sub load
50             {
51 0     0 0   my $self = shift;
52 0           my $data = shift;
53 0           $data =~ s/^\s+//;
54 0           chomp $data;
55 0           my ($node1, $node2, $type) = split ";", $data;
56 0           return $self->new(node1 => $node1, node2 => $node2, type => $type);
57             }
58              
59             1;