File Coverage

blib/lib/Data/ICal/TimeZone/Object.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 3 3 100.0
total 33 33 100.0


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Data::ICal::TimeZone::Object - base class for Data::ICal::TimeZone timezone objects
4              
5             =head1 METHODS
6              
7             =over
8              
9             =item timezone
10              
11             Returns the timezone identifier for the current zone object
12              
13             =item definition
14              
15             Returns a Data::ICal::Entry::TimeZone which defines the given zone.
16              
17             =back
18              
19             =HEAD1 SEE ALSO
20              
21             L
22              
23             =cut
24              
25             package Data::ICal::TimeZone::Object;
26 2     2   12 use strict;
  2         3  
  2         65  
27 2     2   10 use base qw( Class::Singleton Class::Accessor );
  2         2  
  2         1956  
28             __PACKAGE__->mk_accessors(qw( _cal ));
29 2     2   9107 use Data::ICal;
  2         32828  
  2         26  
30              
31             sub new {
32 800     800 1 1489 my $self = shift;
33 800         4989 return $self->instance;
34             }
35              
36             sub definition {
37 401     401 1 1481 my $self = shift;
38 401         10356 my @zones = grep {
39 401         1416 $_->ical_entry_type eq 'VTIMEZONE'
40 401         2082 } @{ $self->_cal->entries };
41 401         3575 return $zones[0];
42             }
43              
44             sub timezone {
45 400     400 1 252513 my $self = shift;
46 400         3267 return $self->definition->property('tzid')->[0]->value;
47             }
48              
49             sub _load {
50 400     400   13186 my $self = shift;
51 400         649 my $ics = shift;
52 400         2480 my $cal = Data::ICal->new( data => $ics );
53 400         1553557 $self->_cal( $cal );
54 400         9989 return;
55             }
56              
57             1;