File Coverage

blib/lib/WWW/ArsenalFC/TicketInformation/Match.pm
Criterion Covered Total %
statement 32 32 100.0
branch 4 6 66.6
condition 2 3 66.6
subroutine 10 10 100.0
pod 5 5 100.0
total 53 56 94.6


line stmt bran cond sub pod time code
1 3     3   29912 use strict;
  3         8  
  3         163  
2 3     3   20 use warnings;
  3         8  
  3         328  
3              
4             package WWW::ArsenalFC::TicketInformation::Match;
5             {
6             $WWW::ArsenalFC::TicketInformation::Match::VERSION = '1.123160';
7             }
8              
9 3     3   3364 use WWW::ArsenalFC::TicketInformation::Match::Availability;
  3         10  
  3         116  
10              
11 3     3   2973 use WWW::ArsenalFC::TicketInformation::Util ':all';
  3         8  
  3         842  
12              
13             # ABSTRACT: Represents an Arsenal match with ticket information.
14              
15 3         20 use Object::Tiny qw{
16             availability
17             can_exchange
18             competition
19             category
20             datetime_string
21             fixture
22             hospitality
23             is_soldout
24 3     3   19 };
  3         6  
25              
26             sub is_home {
27 2     2 1 2528 my ($self) = @_;
28 2         57 return $self->fixture =~ /^Arsenal/;
29             }
30              
31             sub is_premier_league {
32 2     2 1 943 my ($self) = @_;
33 2         60 return $self->competition =~ /Premier League/;
34             }
35              
36             sub datetime {
37 11     11 1 426 my ($self) = @_;
38              
39 11 50       267 if ( $self->datetime_string =~ /\w+\W+(\w+)\D+(\d+)\D+(\d+)\D+(\d\d:\d\d)/ )
40             {
41 11         159 my $month = month_to_number($1);
42 11         32 my $day = $2;
43 11         28 my $year = $3;
44 11         49 my $time = $4;
45              
46 11 100       48 $day = "0$day" if $day =~ /^\d$/;
47 11         125 return sprintf( "%s-%s-%sT%s:00", $year, $month, $day, $time );
48             }
49             }
50              
51             sub date {
52 10     10 1 16 my ($self) = @_;
53 10         35 return substr( $self->datetime, 0, 10 );
54             }
55              
56             sub opposition {
57 11     11 1 456 my ($self) = @_;
58 11 50 66     419 if ( $self->fixture =~ /Arsenal vs (.*)/
59             || $self->fixture =~ /(.*) vs Arsenal/ )
60             {
61 11         365 return $1;
62             }
63             }
64              
65             1;
66              
67              
68              
69             =pod
70              
71             =head1 NAME
72              
73             WWW::ArsenalFC::TicketInformation::Match - Represents an Arsenal match with ticket information.
74              
75             =head1 VERSION
76              
77             version 1.123160
78              
79             =head1 ATTRIBUTES
80              
81             =head2 availability
82              
83             An array of L objects.
84              
85             The first item in the array is the current availability. Second item is the next availability, and so on.
86              
87             Note if the match is sold out or if the ticket exchange is open, this will not be set.
88              
89             =head2 can_exchange
90              
91             True if the ticket exchange is open, otherwise false.
92              
93             =head2 competition
94              
95             The competition the game is being played in (i.e. 'Barclays Premier League').
96              
97             =head2 category
98              
99             The category of the game, if its a Permier League game.
100              
101             =head2 datetime_string
102              
103             The date and time of the game as it is displayed on the website (i.e. 'Saturday, May 5, 2012, 12:45').
104              
105             =head2 fixture
106              
107             The fixture (i.e. 'Arsenal vs Norwich').
108              
109             =head2 hospitality
110              
111             True if hospitality is available, otherwise false.
112              
113             =head2 is_soldout
114              
115             True if sold out, otherwise false.
116              
117             =head1 METHODS
118              
119             =head2 is_home
120              
121             True if Arsenal are at home, otherwise false.
122              
123             =head2 is_premier_league
124              
125             True if this is a Premier League game.
126              
127             =head2 datetime
128              
129             Returns the date and time of the match as C.
130              
131             =head2 date
132              
133             Returns the date of the match as C
134              
135             =head2 opposition
136              
137             Returns the opposition.
138              
139             =head1 AUTHOR
140              
141             Andrew Jones
142              
143             =head1 COPYRIGHT AND LICENSE
144              
145             This software is copyright (c) 2012 by Andrew Jones.
146              
147             This is free software; you can redistribute it and/or modify it under
148             the same terms as the Perl 5 programming language system itself.
149              
150             =cut
151              
152              
153             __END__