File Coverage

blib/lib/Data/ICal/Entry/Event.pm
Criterion Covered Total %
statement 22 22 100.0
branch 6 8 75.0
condition n/a
subroutine 7 7 100.0
pod 4 4 100.0
total 39 41 95.1


line stmt bran cond sub pod time code
1 3     3   1148 use warnings;
  3         6  
  3         116  
2 3     3   15 use strict;
  3         6  
  3         95  
3              
4             package Data::ICal::Entry::Event;
5              
6 3     3   14 use base qw/Data::ICal::Entry/;
  3         5  
  3         961  
7              
8             =head1 NAME
9              
10             Data::ICal::Entry::Event - Represents an event in an iCalendar file
11              
12             =head1 SYNOPSIS
13              
14             my $vevent = Data::ICal::Entry::Event->new();
15             $vevent->add_properties(
16             summary => "my party",
17             description => "I'll cry if I want to",
18             # Dat*e*::ICal is not a typo here
19             dtstart => Date::ICal->new( epoch => time )->ical,
20             );
21              
22             $calendar->add_entry($vevent);
23              
24             $vevent->add_entry($alarm);
25              
26             =head1 DESCRIPTION
27              
28             A L object represents a single event in an
29             iCalendar file. (Note that the iCalendar RFC refers to entries as
30             "components".) It is a subclass of L and accepts
31             all of its methods.
32              
33             =head1 METHODS
34              
35             =cut
36              
37             =head2 ical_entry_type
38              
39             Returns C, its iCalendar entry name.
40              
41             =cut
42              
43 16     16 1 3222 sub ical_entry_type {'VEVENT'}
44              
45             =head2 mandatory_unique_properties
46              
47             The C property is mandatory if C was passed to
48             L.
49              
50             =cut
51              
52             sub mandatory_unique_properties {
53 255     255 1 358 my $self = shift;
54 255 50       449 return $self->rfc_strict ? ("uid") : ()
55             }
56              
57             =head2 optional_unique_properties
58              
59             According to the iCalendar standard, the following properties may be
60             specified at most one time for an event:
61              
62             class created description dtstart geo
63             last-modified location organizer priority
64             dtstamp sequence status summary transp
65             uid url recurrence-id
66              
67             In addition, C and C may be specified at most once
68             each, but not both in the same entry (though this restriction is not
69             enforced).
70              
71             Or if C<< vcal10 => 1 >>:
72              
73             class dcreated completed description dtstart dtend
74             last-modified location rnum priority
75             sequence status summary transp
76             url uid
77              
78             =cut
79              
80             sub optional_unique_properties {
81 250     250 1 1385 my $self = shift;
82 250 50       450 my @ret = $self->rfc_strict ? () : ("uid");
83 250 100       2365 if (not $self->vcal10) {
84 100         1137 push @ret, qw(
85             class created description dtstart geo
86             last-modified location organizer priority
87             dtstamp sequence status summary transp
88             url recurrence-id
89              
90             dtend duration
91             );
92             } else {
93 150         1492 push @ret, qw(
94             class dcreated completed description dtstart dtend
95             last-modified location rnum priority
96             sequence status summary transp
97             url
98             );
99             }
100 250         1274 return @ret;
101             }
102              
103             =head2 optional_repeatable_properties
104              
105             According to the iCalendar standard, the following properties may be
106             specified any number of times for an event:
107              
108             attach attendee categories comment
109             contact exdate exrule request-status related-to
110             resources rdate rrule
111              
112             Or if C<< vcal10 => 1 >>:
113              
114             aalarm attach attendee categories
115             dalarm exdate exrule malarm palarm related-to
116             resources rdate rrule
117              
118             =cut
119              
120             sub optional_repeatable_properties {
121 125     125 1 179 my $self = shift;
122 125 100       228 if (not $self->vcal10) {
123 50         547 qw(
124             attach attendee categories comment
125             contact exdate exrule request-status related-to
126             resources rdate rrule
127             );
128             } else {
129 75         806 qw(
130             aalarm attach attendee categories
131             dalarm exdate exrule malarm palarm related-to
132             resources rdate rrule
133             );
134             }
135             }
136              
137             =head1 SEE ALSO
138              
139             =over 4
140              
141             =item L
142              
143             For date parsing and formatting, including denoting "all day" events,
144             considering using this module. Because it's a "mix in", you can still
145             use all the methods here as well as the new date handling methods it
146             defines.
147              
148             =back
149              
150             =head1 AUTHOR
151              
152             Best Practical Solutions, LLC Emodules@bestpractical.comE
153              
154             =head1 LICENCE AND COPYRIGHT
155              
156             Copyright (c) 2005 - 2020, Best Practical Solutions, LLC. All rights reserved.
157              
158             This module is free software; you can redistribute it and/or
159             modify it under the same terms as Perl itself. See L.
160              
161             =cut
162              
163             1;