Acme-2zicon

 view release on metacpan or  search on metacpan

cpanfile  view on Meta::CPAN

requires 'perl', '5.008001';
requires 'Class::Accessor';
requires 'DateTime';

on 'test' => sub {
    requires 'Test::More', '0.98';
};

lib/Acme/2zicon.pm  view on Meta::CPAN

    NakamuraAkari
    NemotoNagi
    OkumuraNonoka
    ShigematsuYuka
    SuyamaEmiri
    TsurumiMoe
    OtsukaMiyu
    YamatoAo
);

sub new {
    my $class = shift;
    my $self  = bless {members => []}, $class;

    $self->_initialize;

    return $self;
}

sub members {
    my ($self, $type, @members) = @_;
    @members = @{$self->{members}} unless @members;

    return @members unless $type;
}

sub sort {
    my ($self, $type, $order, @members) = @_;
    @members = $self->members unless @members;

    # order by desc if $order is true
    if ($order) {
        return sort {$b->$type <=> $a->$type} @members;
    }
    else {
        return sort {$a->$type <=> $b->$type} @members;
    }
}

sub select {
    my ($self, $type, $number, $operator, @members) = @_;

    $self->_die('invalid operator was passed in')
        unless grep {$operator eq $_} qw(== >= <= > <);

    @members = $self->members unless @members;
    my $compare = eval "(sub { \$number $operator \$_[0] })";

    return grep { $compare->($_->$type) } @members;
}

sub _initialize {
    my $self = shift;

    for my $member (@members) {
        my $module_name = 'Acme::2zicon::'.$member;

        eval qq|require $module_name;|;
        push @{$self->{members}}, $module_name->new;
    }

    return 1;
}

sub _die {
    my ($self, $message) = @_;
    Carp::croak($message);
}

1;
__END__

=encoding utf-8

=head1 NAME

lib/Acme/2zicon/Base.pm  view on Meta::CPAN

    family_name_en
    nick
    birthday
    age
    blood_type
    hometown
    introduction
    twitter
));

sub new {
    my $class = shift;
    my $self  = bless {}, $class;

    $self->_initialize;

    return $self;
}

sub _initialize {
    my $self = shift;
    my %info = $self->info;

    $self->{$_}      = $info{$_} for keys %info;
    $self->{name_ja} = $self->family_name_ja.$self->first_name_ja;
    $self->{name_en} = $self->first_name_en.' '.$self->family_name_en;
    $self->{age}     = $self->_calculate_age;
    $self->{introduction} = $self->_introduction($info{introduction});

    return 1;
}

sub _calculate_age {
    my $self  = shift;
    my $today = DateTime->today;

    if (($today->month - $self->birthday->month) >= 0) {
        if (($today->day - $self->birthday->day  ) >= 0) {
            return $today->year - $self->birthday->year;
        } else {
            return ($today->year - $self->birthday->year) - 1;
        }
    } else {
        return ($today->year - $self->birthday->year) - 1;
    }
}

sub _datetime_from_date {
    my ($self, $date) = @_;
    my ($year, $month, $day) = ($date =~ /(\d{4})\.(\d{2})\.(\d{2})/);

    DateTime->new(
        year  => $year,
        month => $month,
        day   => $day,
    );
}

sub _introduction {
    my ($self, $introduction) = @_;
    $introduction =~ s/\[(\w+)\]/$self->{$1}/g;
    return $introduction;
}

1;

__END__

=head1 NAME

lib/Acme/2zicon/MatobaKarin.pm  view on Meta::CPAN

package Acme::2zicon::MatobaKarin;

use strict;
use warnings;

use base qw(Acme::2zicon::Base);

our $VERSION = '0.7';

sub info {
    my $self = shift;
    return (
        first_name_ja  => '華鈴',
        family_name_ja => 'çš„å ´',
        first_name_en  => 'Karin',
        family_name_en => 'Matoba',
        nick           => [qw(かりん かりんさま)],
        birthday       => $self->_datetime_from_date('2000.12.30'),
        blood_type     => 'A',
        hometown       => '埼玉県',

lib/Acme/2zicon/NakamuraAkari.pm  view on Meta::CPAN

package Acme::2zicon::NakamuraAkari;

use strict;
use warnings;

use base qw(Acme::2zicon::Base);

our $VERSION = '0.7';

sub info {
    my $self = shift;
    return (
        first_name_ja  => '朱里',
        family_name_ja => '中村',
        first_name_en  => 'Akari',
        family_name_en => 'Nakamura',
        nick           => [qw(あかりん)],
        birthday       => $self->_datetime_from_date('1998.01.30'),
        blood_type     => 'B',
        hometown       => '千葉県',

lib/Acme/2zicon/NemotoNagi.pm  view on Meta::CPAN

package Acme::2zicon::NemotoNagi;

use strict;
use warnings;

use base qw(Acme::2zicon::Base);

our $VERSION = '0.7';

sub info {
    my $self = shift;
    return (
        first_name_ja  => '凪',
        family_name_ja => '根本',
        first_name_en  => 'Nagi',
        family_name_en => 'Nemoto',
        nick           => [qw(ねも)],
        birthday       => $self->_datetime_from_date('1999.03.15'),
        blood_type     => 'B',
        hometown       => '茨城県',

lib/Acme/2zicon/OkumuraNonoka.pm  view on Meta::CPAN

package Acme::2zicon::OkumuraNonoka;

use strict;
use warnings;

use base qw(Acme::2zicon::Base);

our $VERSION = '0.7';

sub info {
    my $self = shift;
    return (
        first_name_ja  => '野乃花',
        family_name_ja => '奥村',
        first_name_en  => 'Nonoka',
        family_name_en => 'Okumura',
        nick           => [qw(ののた)],
        birthday       => $self->_datetime_from_date('2001.01.04'),
        blood_type     => 'O',
        hometown       => '東京都',

lib/Acme/2zicon/OtsukaMiyu.pm  view on Meta::CPAN

package Acme::2zicon::OtsukaMiyu;

use strict;
use warnings;

use base qw(Acme::2zicon::Base);

our $VERSION = '0.7';

sub info {
    my $self = shift;
    return (
        first_name_ja  => '望由',
        family_name_ja => '大塚',
        first_name_en  => 'Miyu',
        family_name_en => 'Otsuka',
        nick           => [qw(ミユミユ)],
        birthday       => $self->_datetime_from_date('2000.12.20'),
        blood_type     => 'O',
        hometown       => 'ドイツ',

lib/Acme/2zicon/ShigematsuYuka.pm  view on Meta::CPAN

package Acme::2zicon::ShigematsuYuka;

use strict;
use warnings;

use base qw(Acme::2zicon::Base);

our $VERSION = '0.7';

sub info {
    my $self = shift;
    return (
        first_name_ja  => '佑佳',
        family_name_ja => '重松',
        first_name_en  => 'Yuka',
        family_name_en => 'Shigematsu',
        nick           => [qw(しげちー)],
        birthday       => $self->_datetime_from_date('1996.05.20'),
        blood_type     => 'B',
        hometown       => '福岡県',

lib/Acme/2zicon/SuyamaEmiri.pm  view on Meta::CPAN

package Acme::2zicon::SuyamaEmiri;

use strict;
use warnings;

use base qw(Acme::2zicon::Base);

our $VERSION = '0.7';

sub info {
    my $self = shift;
    return (
        first_name_ja  => '恵実里',
        family_name_ja => '陶山',
        first_name_en  => 'Emiri',
        family_name_en => 'Suyama',
        nick           => [qw(えみりぃ)],
        birthday       => $self->_datetime_from_date('1999.05.26'),
        blood_type     => 'O',
        hometown       => '東京都',

lib/Acme/2zicon/TsurumiMoe.pm  view on Meta::CPAN

package Acme::2zicon::TsurumiMoe;

use strict;
use warnings;

use base qw(Acme::2zicon::Base);

our $VERSION = '0.7';

sub info {
    my $self = shift;
    return (
        first_name_ja  => '萌',
        family_name_ja => '鶴見',
        first_name_en  => 'Moe',
        family_name_en => 'Tsurumi',
        nick           => [qw(もえ)],
        birthday       => $self->_datetime_from_date('1996.12.05'),
        blood_type     => 'A',
        hometown       => '東京都',

lib/Acme/2zicon/YamatoAo.pm  view on Meta::CPAN

package Acme::2zicon::YamatoAo;

use strict;
use warnings;

use base qw(Acme::2zicon::Base);

our $VERSION = '0.7';

sub info {
    my $self = shift;
    return (
        first_name_ja  => '明桜',
        family_name_ja => '大和',
        first_name_en  => 'Ao',
        family_name_en => 'Yamato',
        nick           => [qw(あおちゃん)],
        birthday       => $self->_datetime_from_date('2002.05.23'),
        blood_type     => 'B',
        hometown       => '東京都',

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.690 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )