| 1 | package Acme::Nogizaka46::Base; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 3 | ▶ | use DateTime; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 3 | ▶ | use base qw(Class::Accessor); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 3 | our $VERSION = '0.0.1'; | |||||||||||||
| 9 | |||||||||||||||
| 10 | 3 | __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 | class | ||||||||||||||
| 23 | center | ||||||||||||||
| 24 | graduate_date | ||||||||||||||
| 25 | )); | ||||||||||||||
| 26 | |||||||||||||||
| 27 | sub new { | ||||||||||||||
| 28 | 153 | ▶ | my $class = shift; | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 29 | 153 | my $self = bless {}, $class; | |||||||||||||
| 30 | |||||||||||||||
| 31 | 153 | $self->_initialize; | |||||||||||||
| 32 | |||||||||||||||
| 33 | 153 | return $self; | |||||||||||||
| 34 | } | ||||||||||||||
| 35 | |||||||||||||||
| 36 | sub _initialize { | ||||||||||||||
| 37 | 153 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
_initialize: called CC=2 SCAR=6.9
| |||||||||||||||
| 38 | 153 | my %info = $self->info; | |||||||||||||
| 39 | |||||||||||||||
| 40 | 153 | $self->{$_} = $info{$_} for keys %info; | |||||||||||||
| 41 | 153 | $self->{name_ja} = $self->family_name_ja.$self->first_name_ja; | |||||||||||||
| 42 | 153 | $self->{name_en} = $self->first_name_en.' '.$self->family_name_en; | |||||||||||||
| 43 | 153 | $self->{age} = $self->_calculate_age; | |||||||||||||
| 44 | |||||||||||||||
| 45 | 153 | return 1; | |||||||||||||
| 46 | } | ||||||||||||||
| 47 | |||||||||||||||
| 48 | sub _calculate_age { | ||||||||||||||
| 49 | 153 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
_calculate_age: called CC=4 SCAR=14.0
| |||||||||||||||
| 50 | 153 | my $today = DateTime->today; | |||||||||||||
| 51 | |||||||||||||||
| 52 | 153 | ▶ | if (($today->month - $self->birthday->month) > 0) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 53 | 78 | return $today->year - $self->birthday->year; | |||||||||||||
| 54 | } elsif (($today->month - $self->birthday->month) == 0) { | ||||||||||||||
| 55 | 15 | ▶ | if (($today->day - $self->birthday->day ) >= 0) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 56 | 15 | return $today->year - $self->birthday->year; | |||||||||||||
| 57 | } else { | ||||||||||||||
| 58 | 0 | return ($today->year - $self->birthday->year) - 1; | |||||||||||||
| 59 | } | ||||||||||||||
| 60 | } else { | ||||||||||||||
| 61 | 60 | return ($today->year - $self->birthday->year) - 1; | |||||||||||||
| 62 | } | ||||||||||||||
| 63 | } | ||||||||||||||
| 64 | |||||||||||||||
| 65 | sub _datetime_from_date { | ||||||||||||||
| 66 | 195 | ▶ | my ($self, $date) = @_; | ||||||||||||
|
Subroutine
_datetime_from_date: called CC=1 SCAR=0.0
| |||||||||||||||
| 67 | 195 | my ($year, $month, $day) = ($date =~ /(\d{4})-(\d{2})-(\d{2})/); | |||||||||||||
| 68 | |||||||||||||||
| 69 | 195 | DateTime->new( | |||||||||||||
| 70 | year => $year, | ||||||||||||||
| 71 | month => $month, | ||||||||||||||
| 72 | day => $day, | ||||||||||||||
| 73 | ); | ||||||||||||||
| 74 | } | ||||||||||||||
| 75 | |||||||||||||||
| 76 | 3 | 1; | |||||||||||||
| 77 | |||||||||||||||
| 78 | __END__ | ||||||||||||||
| 79 | |||||||||||||||
| 80 | =head1 NAME | ||||||||||||||
| 81 | |||||||||||||||
| 82 | Acme::Nogizaka46::Base - A baseclass of the class represents each | ||||||||||||||
| 83 | member of Nogizaka46. | ||||||||||||||
| 84 | |||||||||||||||
| 85 | =head1 SYNOPSIS | ||||||||||||||
| 86 | |||||||||||||||
| 87 | use Acme::Nogizaka46; | ||||||||||||||
| 88 | |||||||||||||||
| 89 | my $nogizaka = Acme::Nogizaka46->new; | ||||||||||||||
| 90 | |||||||||||||||
| 91 | # retrieve the members as a list of | ||||||||||||||
| 92 | # Acme::Nogizaka46::Base based objects | ||||||||||||||
| 93 | my @members = $nogizaka->members; | ||||||||||||||
| 94 | |||||||||||||||
| 95 | for my $member (@members) { | ||||||||||||||
| 96 | my $name_ja = $member->name_ja; | ||||||||||||||
| 97 | my $first_name_ja = $member->first_name_ja; | ||||||||||||||
| 98 | my $family_name_ja = $member->family_name_ja; | ||||||||||||||
| 99 | my $name_en = $member->name_en; | ||||||||||||||
| 100 | my $first_name_en = $member->first_name_en; | ||||||||||||||
| 101 | my $family_name_en = $member->family_name_en; | ||||||||||||||
| 102 | my $nick = $member->nick; # arrayref | ||||||||||||||
| 103 | my $birthday = $member->birthday; # DateTime object | ||||||||||||||
| 104 | my $age = $member->age; | ||||||||||||||
| 105 | my $blood_type = $member->blood_type; | ||||||||||||||
| 106 | my $hometown = $member->hometown; | ||||||||||||||
| 107 | my $emoticon = $member->emoticon; # arrayref | ||||||||||||||
| 108 | my $class = $member->class; | ||||||||||||||
| 109 | my $graduate_date = $member->graduate_date; # DateTime object | ||||||||||||||
| 110 | } | ||||||||||||||
| 111 | |||||||||||||||
| 112 | =head1 DESCRIPTION | ||||||||||||||
| 113 | |||||||||||||||
| 114 | Acme::Nogizaka46::Base is a baseclass of the class represents each | ||||||||||||||
| 115 | member of Nogizaka46. | ||||||||||||||
| 116 | |||||||||||||||
| 117 | =head1 ACCESSORS | ||||||||||||||
| 118 | |||||||||||||||
| 119 | =head2 name_ja | ||||||||||||||
| 120 | |||||||||||||||
| 121 | =head2 first_name_ja | ||||||||||||||
| 122 | |||||||||||||||
| 123 | =head2 family_name_ja | ||||||||||||||
| 124 | |||||||||||||||
| 125 | =head2 name_en | ||||||||||||||
| 126 | |||||||||||||||
| 127 | =head2 first_name_en | ||||||||||||||
| 128 | |||||||||||||||
| 129 | =head2 family_name_en | ||||||||||||||
| 130 | |||||||||||||||
| 131 | =head2 nick | ||||||||||||||
| 132 | |||||||||||||||
| 133 | =head2 birthday | ||||||||||||||
| 134 | |||||||||||||||
| 135 | =head2 age | ||||||||||||||
| 136 | |||||||||||||||
| 137 | =head2 blood_type | ||||||||||||||
| 138 | |||||||||||||||
| 139 | =head2 hometown | ||||||||||||||
| 140 | |||||||||||||||
| 141 | =head2 emoticon | ||||||||||||||
| 142 | |||||||||||||||
| 143 | =head2 class | ||||||||||||||
| 144 | |||||||||||||||
| 145 | =head2 graduate_date | ||||||||||||||
| 146 | |||||||||||||||
| 147 | =head1 SEE ALSO | ||||||||||||||
| 148 | |||||||||||||||
| 149 | =over 4 | ||||||||||||||
| 150 | |||||||||||||||
| 151 | =item * L<DateTime> | ||||||||||||||
| 152 | |||||||||||||||
| 153 | =back | ||||||||||||||
| 154 | |||||||||||||||
| 155 | =head1 AUTHOR | ||||||||||||||
| 156 | |||||||||||||||
| 157 | Kentaro Kuribayashi E<lt>kentaro@cpan.orgE<gt> | ||||||||||||||
| 158 | |||||||||||||||
| 159 | =head1 COPYRIGHT AND LICENSE (The MIT License) | ||||||||||||||
| 160 | |||||||||||||||
| 161 | Copyright (c) 2015, Takaaki TSUJIMOTO E<lt>2gmon.t@gmail.comE<gt> | ||||||||||||||
| 162 | |||||||||||||||
| 163 | Original Copyright (c) 2005 - 2007, Kentaro Kuribayashi | ||||||||||||||
| 164 | E<lt>kentaro@cpan.orgE<gt> | ||||||||||||||
| 165 | |||||||||||||||
| 166 | Permission is hereby granted, free of charge, to any person obtaining | ||||||||||||||
| 167 | a copy of this software and associated documentation files (the | ||||||||||||||
| 168 | "Software"), to deal in the Software without restriction, including | ||||||||||||||
| 169 | without limitation the rights to use, copy, modify, merge, publish, | ||||||||||||||
| 170 | distribute, sublicense, and/or sell copies of the Software, and to | ||||||||||||||
| 171 | permit persons to whom the Software is furnished to do so, subject to | ||||||||||||||
| 172 | the following conditions: | ||||||||||||||
| 173 | |||||||||||||||
| 174 | The above copyright notice and this permission notice shall be | ||||||||||||||
| 175 | included in all copies or substantial portions of the Software. | ||||||||||||||
| 176 | |||||||||||||||
| 177 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||||||||||||
| 178 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||||||||||||
| 179 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||||||||||||
| 180 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||||||||||||||
| 181 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||||||||||||||
| 182 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||||||||||||||
| 183 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||||||||||||
| 184 | |||||||||||||||
| 185 | =cut | ||||||||||||||