File Coverage

blib/lib/Acme/MadokaMagica/TvMembers.pm
Criterion Covered Total %
statement 85 94 90.4
branch 19 28 67.8
condition n/a
subroutine 17 17 100.0
pod 0 12 0.0
total 121 151 80.1


line stmt bran cond sub pod time code
1             package Acme::MadokaMagica::TvMembers;
2 3     3   1353 use strict;
  3         7  
  3         89  
3 3     3   15 use warnings;
  3         5  
  3         93  
4 3     3   15 use utf8;
  3         6  
  3         20  
5 3     3   1458 use Data::Section::Simple;
  3         1754  
  3         151  
6 3     3   1687 use YAML::Tiny;
  3         17237  
  3         2624  
7              
8             sub new {
9 18     18 0 12770 my ($class, %args) = @_;
10              
11 18         51 my $self = { _has_qb => undef };
12 18         77 my $ds = Data::Section::Simple->new($class);
13 18         145 my $sections = $ds->get_data_section;
14 18         1686 for my $section_name ( keys %{$sections} ) {
  18         71  
15 18         85 my $yml = YAML::Tiny->read_string($sections->{$section_name});
16 18         9727 my $member_info = $yml->[0];
17 18         33 for my $key ( keys %{$member_info} ) {
  18         95  
18 162         479 $self->{$key} = $member_info->{$key};
19             }
20             }
21 18 100       59 if (defined $args{line}) {
22 13         27 $self->{startline} = $args{line};
23             } else {
24 5         20 $self->{startline} = (caller)[2];
25             }
26              
27 18         130 return bless $self, $class;
28             }
29              
30             sub has_qb {
31 46     46 0 108 my $self = shift;
32              
33 46 100       109 if (@_){
34 7         14 $self->{_has_qb} = shift;
35             }
36              
37 46         276 return $self->{_has_qb};
38             }
39              
40             sub name {
41 16     16 0 4758 my ($self) = @_;
42 16         51 my $line = (caller)[2];
43              
44 16         44 my $limit = $self->{startline} +100;
45 16 50       53 if( $line >= $limit ) {
46 0         0 return undef;
47             }
48 16 100       40 return $self->has_qb ? $self->{witchename} : $self->lastname.' '.$self->firstname;
49             }
50              
51             sub firstname {
52 14     14 0 29 my $self = shift;
53 14         37 my $line = (caller)[2];
54              
55 14         30 my $limit = $self->{startline} +100;
56 14 50       31 if($line >= $limit ) {
57 0         0 return undef;
58             }
59 14         70 return $self->{firstname};
60             }
61              
62             sub birthday {
63 5     5 0 13 my $self = shift;
64 5         18 my $line = (caller)[2];
65              
66 5         12 my $limit = $self->{startline} +100;
67 5 50       14 if($line >= $limit ) {
68 0         0 return undef;
69             }
70 5         24 return $self->{birthday};
71             }
72              
73             sub blood_type {
74 5     5 0 12 my $self = shift;
75 5         15 my $line = (caller)[2];
76              
77 5         13 my $limit = $self->{startline} +100;
78 5 50       15 if( $line >= $limit ) {
79 0         0 return undef;
80             }
81 5         26 return $self->{blood_type};
82             }
83              
84             sub lastname {
85 14     14 0 29 my $self = shift;
86 14         42 my $line = (caller)[2];
87              
88 14         33 my $limit = $self->{startline} +100;
89 14 50       32 if( $line >= $limit ) {
90 0         0 return undef;
91             }
92 14         72 return $self->{lastname};
93             }
94              
95             sub age {
96 5     5 0 12 my $self = shift;
97 5         16 my $line = (caller)[2];
98              
99 5         12 my $limit = $self->{startline} +100;
100 5 50       15 if( $line >= $limit ) {
101 0         0 return undef;
102             }
103 5         21 return $self->{age};
104             }
105              
106             sub color{
107 15     15 0 1498 my ($self) = @_;
108 15         55 my $line = (caller)[2];
109              
110 15         42 my $limit = $self->{startline} +100;
111 15 100       48 if( $line >= $limit ) {
112 2         10 return undef;
113             }
114              
115 13 100       35 return $self->has_qb ? "black" : $self->{color};
116             }
117              
118             sub qb {
119 7     7 0 31 my ($self) = @_;
120 7         50 my $line = (caller)[2];
121              
122 7         39 my $limit = $self->{startline} +100;
123 7 50       24 if( $line >= $limit ) {
124 0         0 return undef;
125             }
126              
127 7         19 $self->has_qb(1);
128             }
129              
130             sub say {
131 8     8 0 1273 my ($self) = @_;
132 8         25 my $line = (caller)[2];
133              
134 8         24 my $limit = $self->{startline} +100;
135 8 50       23 if( $line >= $limit ) {
136 0         0 return undef;
137             }
138 8         33 return $self->{say};
139             }
140              
141             sub cv {
142 5     5 0 12 my $self = shift;
143 5         16 my $line = (caller)[2];
144              
145 5         11 my $limit = $self->{startline} +100;
146 5 50       15 if( $line >= $limit ) {
147 0         0 return undef;
148             }
149 5         29 return $self->{cv};
150             }
151              
152              
153             1;