1 # This file is part of Email-Reminder.
3 # Email-Reminder is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License as
5 # published by the Free Software Foundation; either version 3 of the
6 # License, or (at your option) any later version.
8 # Email-Reminder is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with Email-Reminder; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 package EmailReminder
::BirthdayEvent
;
22 use overload
'""' => \
&str
;
23 use EmailReminder
::Utils
;
24 use EmailReminder
::YearlyEvent
;
26 use base
qw(EmailReminder::YearlyEvent);
29 __PACKAGE__
->mk_accessors(qw(email));
33 return $self->get_type . ':' . $self->get_id . ') ' . $self->get_name . ' - ' . $self->get_date;
36 # Hard-coded value for this event's type (class method)
42 # Number of fields this event adds to its parent (class method)
46 return $self->SUPER::get_nb_fields
() + 1;
51 my ($class, $new_value) = @_;
52 # ToDo: do checking on the email address
56 # Returns the age of the person (starts at 0 years old)
61 my $age = $self->EmailReminder::YearlyEvent
::get_occurence
();
63 return defined($age) ?
($age - 1) : undef;
70 my $name = $self->get_name();
71 my $age = $self->get_occurence();
72 my $when = $self->{"WHEN"};
74 if ($age and $when eq "today") {
75 return "$name is now $age";
78 return "${name}'s birthday";
87 my $name = $self->get_name();
88 my $email = $self->get_email();
89 my $age = $self->get_occurence();
90 my $when = $self->{"WHEN"};
92 my $age_string = $age ?
"turning $age" : "getting one year older";
93 my $email_message = $email ?
"\n\nYou can reach $name at $email." : "";
95 my $message = <<"MESSAGEEND";
96 I just want to remind you that $name is $age_string $when.$email_message