| 1 | package WWW::PTV::TimeTable::Schedule; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | my ($class, $schedule) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | $self->{schedule} = $schedule; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | return $self | |||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub as_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_list: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | return @{ $_[0]->{schedule} }; | |||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub next { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my ($self, $n, $i) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | $n ||= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$n ||= 1
MC/DC0%0/1
$n ||= 1
$n
Truth table0%0/2
A
A= $n
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | $i ||= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$i ||= 0
MC/DC0%0/1
$i ||= 0
$i
Truth table0%0/2
A
A= $i
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my(@res,$c,$l); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my($h,$m) = (localtime(time))[2,1]; | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | foreach my $t ( @{ $self->{schedule} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | $l++; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my($nh,$nm) = split /:/, $t; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | $nm and $nh ne '-' or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$nm and $nh ne "-"
MC/DC0%0/2
$nm and $nh ne "-"
$nm
$nh ne "-"
Truth table0%0/3
A and B
A= $nmB= $nh ne "-"
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if( ($nh > $h) || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$nh > $h or $nh >= $h and $nm >= $m
$nh >= $h and $nm >= $m
MC/DC0%0/3
$nh > $h or $nh >= $h and $nm >= $m
$nh > $h
$nh >= $h
$nm >= $m
Truth table0%0/4
A or B and C
A= $nh > $hB= $nh >= $hC= $nm >= $m
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | ($nh >= $h && $nm >= $m) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | push @res, [$nh,$nm]; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if( $i == 7 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return $l-1 | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if( ++$c == $n ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | return ( ~~@res == 1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | ? $res[0] | ||||||||||||||||||||||||||||||||||||||||||
| 41 | : \@res ) | ||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return ( @res ? \@res : 0 ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub index_of_next { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_of_next: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return $_[0]->next(1,7) | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub next_five { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_five: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | return $_[0]->next(5) | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub pretty_print { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pretty_print: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $self= shift; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my @t = localtime(time); | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $i = $self->index_of_next; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my @s = $self->as_list; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $n = $s[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my @d = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday | |||||||||||||||||||||||||||||||||||||||||
| 64 | Sunday); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my @m = qw(January February March April May June July August September | |||||||||||||||||||||||||||||||||||||||||
| 66 | October November December); | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | printf("Current local time and date is: %s %s %s %02d:%02d %s\n", | |||||||||||||||||||||||||||||||||||||||||
| 68 | $d[$t[6]], $t[3], $m[$t[4]], $t[2], $t[1], ($t[5]+1900)); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | @s = map { sprintf("| %-6s |\n", $_ ) } @s; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $s[$i] = "===== Next service =====\n" | |||||||||||||||||||||||||||||||||||||||||
| 71 | . " $n\n" | ||||||||||||||||||||||||||||||||||||||||||
| 72 | . "========================\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | @s = grep { /:/ } @s; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | push @s, ""; unshift @s, ""; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | print join "+--------+\n", @s; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | __END__ | ||||||||||||||||||||||||||||||||||||||||||