lib/Video/PlaybackMachine/FillProducer/NextSchedule.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran n/a Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 48 CC 1 SCAR 6.9
CC
1
Cov
0%
add_text
2.0
is_available
2.0
BEGIN
2.0
CRAP 2.0
1 package Video::PlaybackMachine::FillProducer::NextSchedule;
2  
3 our $VERSION = '0.09'; # VERSION
4  
5 ####
6 #### Video::PlaybackMachine::FillProducer::NextSchedule
7 ####
8 #### $Revision$
9 ####
10  
11 use Moo;
12  
13 use Carp;
14  
15 extends 'Video::PlaybackMachine::FillProducer::TextFrame';
16  
17 use Video::PlaybackMachine::FillProducer::TextFrame::TextTable;
18 use POE;
19  
20 use POSIX qw(strftime);
21  
22 ############################# Class Constants #############################
23  
24 our $Max_Entries = 5;
25  
26 our $Border = 20;
27  
28 ############################## Class Methods ##############################
29  
30  
31  
32 ############################# Object Methods ##############################
33  
34 ##
35 ## add_text()
36 ##
37 sub add_text {
38 my $self = shift;
39 my ($image) = @_;
40  
41 my @entries = $poe_kernel->call('Scheduler', 'query_next_scheduled', $Max_Entries)
42 or return;
43 my $table =
44 Video::PlaybackMachine::FillProducer::TextFrame::TextTable->new(
45 image => $image,
46 border => $Border,
47 );
48 foreach my $entry (@entries) {
49 my $next_time = strftime '%l:%M', localtime ($entry->start_time());
50 $table->add_row($next_time, $entry->movie_info()->title())
51 or last;
52 }
53  
54 $table->draw();
55  
56 }
57  
58 ##
59 ## is_available
60 ##
61 ## We are available if there is more than one something "next". If
62 ## there's only one thing left on the schedule, we assume that "up
63 ## next" will be enough.
64 ##
65 sub is_available {
66 my $self = shift;
67  
68 my @entries = $poe_kernel->call('Scheduler', 'query_next_scheduled', $Max_Entries)
69 or return;
70  
71 return scalar @entries > 1;
72  
73 }
74  
75  
76 1;