line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::2zicon::Base; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
43
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
32
|
|
5
|
2
|
|
|
2
|
|
7
|
use DateTime; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
32
|
|
6
|
2
|
|
|
2
|
|
4
|
use base qw(Class::Accessor); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
960
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.7'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( |
11
|
|
|
|
|
|
|
name_ja |
12
|
|
|
|
|
|
|
first_name_ja |
13
|
|
|
|
|
|
|
family_name_ja |
14
|
|
|
|
|
|
|
name_en |
15
|
|
|
|
|
|
|
first_name_en |
16
|
|
|
|
|
|
|
family_name_en |
17
|
|
|
|
|
|
|
nick |
18
|
|
|
|
|
|
|
birthday |
19
|
|
|
|
|
|
|
age |
20
|
|
|
|
|
|
|
blood_type |
21
|
|
|
|
|
|
|
hometown |
22
|
|
|
|
|
|
|
introduction |
23
|
|
|
|
|
|
|
twitter |
24
|
|
|
|
|
|
|
)); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
18
|
|
|
18
|
1
|
20
|
my $class = shift; |
28
|
18
|
|
|
|
|
28
|
my $self = bless {}, $class; |
29
|
|
|
|
|
|
|
|
30
|
18
|
|
|
|
|
62
|
$self->_initialize; |
31
|
|
|
|
|
|
|
|
32
|
18
|
|
|
|
|
51
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _initialize { |
36
|
18
|
|
|
18
|
|
18
|
my $self = shift; |
37
|
18
|
|
|
|
|
57
|
my %info = $self->info; |
38
|
|
|
|
|
|
|
|
39
|
18
|
|
|
|
|
3176
|
$self->{$_} = $info{$_} for keys %info; |
40
|
18
|
|
|
|
|
78
|
$self->{name_ja} = $self->family_name_ja.$self->first_name_ja; |
41
|
18
|
|
|
|
|
268
|
$self->{name_en} = $self->first_name_en.' '.$self->family_name_en; |
42
|
18
|
|
|
|
|
195
|
$self->{age} = $self->_calculate_age; |
43
|
18
|
|
|
|
|
238
|
$self->{introduction} = $self->_introduction($info{introduction}); |
44
|
|
|
|
|
|
|
|
45
|
18
|
|
|
|
|
34
|
return 1; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _calculate_age { |
49
|
18
|
|
|
18
|
|
15
|
my $self = shift; |
50
|
18
|
|
|
|
|
41
|
my $today = DateTime->today; |
51
|
|
|
|
|
|
|
|
52
|
18
|
100
|
|
|
|
5507
|
if (($today->month - $self->birthday->month) >= 0) { |
53
|
12
|
100
|
|
|
|
174
|
if (($today->day - $self->birthday->day ) >= 0) { |
54
|
8
|
|
|
|
|
74
|
return $today->year - $self->birthday->year; |
55
|
|
|
|
|
|
|
} else { |
56
|
4
|
|
|
|
|
44
|
return ($today->year - $self->birthday->year) - 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} else { |
59
|
6
|
|
|
|
|
84
|
return ($today->year - $self->birthday->year) - 1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _datetime_from_date { |
64
|
18
|
|
|
18
|
|
23
|
my ($self, $date) = @_; |
65
|
18
|
|
|
|
|
99
|
my ($year, $month, $day) = ($date =~ /(\d{4})\.(\d{2})\.(\d{2})/); |
66
|
|
|
|
|
|
|
|
67
|
18
|
|
|
|
|
78
|
DateTime->new( |
68
|
|
|
|
|
|
|
year => $year, |
69
|
|
|
|
|
|
|
month => $month, |
70
|
|
|
|
|
|
|
day => $day, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _introduction { |
75
|
18
|
|
|
18
|
|
22
|
my ($self, $introduction) = @_; |
76
|
18
|
|
|
|
|
168
|
$introduction =~ s/\[(\w+)\]/$self->{$1}/g; |
77
|
18
|
|
|
|
|
38
|
return $introduction; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |