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
;
27 our @ISA = ("EmailReminder::YearlyEvent", "Exporter");
28 our @EXPORT = qw(get_th get_email);
30 # XML tags, attributes and values
31 my $EMAIL_TAG = 'email';
35 return $this->get_type . ':' . $this->get_id . ') ' . $this->get_name . ' - ' . $this->get_date;
38 # Hard-coded value for this event's type (class method)
44 # Number of fields this event adds to its parent (class method)
47 return EmailReminder
::YearlyEvent
->get_nb_fields() + 1;
53 return EmailReminder
::Utils
::get_node_value
($this->{XML_NODE
}, $EMAIL_TAG);
58 my ($this, $new_value) = @_;
59 return EmailReminder
::Utils
::set_node_value
($this->{XML_NODE
}, $EMAIL_TAG, $new_value);
62 # Returns the age of the person (starts at 0 years old)
67 my $age = $this->EmailReminder::YearlyEvent
::get_occurence
();
69 return defined($age) ?
($age - 1) : undef;
76 my $name = $this->get_name();
77 my $age = $this->get_occurence();
78 my $when = $this->{"WHEN"};
80 if ($age and $when eq "today") {
81 return "$name is now $age";
84 return "${name}'s birthday";
93 my $first_name = shift;
96 my $name = $this->get_name();
97 my $email = $this->get_email();
98 my $age = $this->get_occurence();
99 my $when = $this->{"WHEN"};
101 my $age_string = $age ?
"turning $age" : "getting one year older";
102 my $email_message = $email ?
"\n\nYou can reach $name at $email." : "";
104 my $message = <<MESSAGEEND;
107 I just want to remind you that $name is $age_string $when.$email_message