| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::PTV::TimeTable; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
10
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
45
|
|
|
4
|
2
|
|
|
2
|
|
33
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
47
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1103
|
use WWW::PTV::TimeTable::Schedule; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
59
|
|
|
7
|
2
|
|
|
2
|
|
12
|
use Carp qw(croak); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1364
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ATTR = qw( route_id direction direction_desc name ); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
0
|
|
|
0
|
0
|
|
my ( $class, $stop_names, $stop_ids, $stop_times ) = @_; |
|
13
|
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
|
15
|
0
|
|
|
|
|
|
$self->{stop_names} = $stop_names; |
|
16
|
0
|
|
|
|
|
|
$self->{stop_ids} = $stop_ids; |
|
17
|
0
|
|
|
|
|
|
$self->{stop_times} = $stop_times; |
|
18
|
0
|
|
|
|
|
|
@{ $self->{map} }{ @{ $self->{stop_ids} } } = @{ $self->{stop_times} }; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
return $self |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub stop_ids { |
|
24
|
0
|
|
|
0
|
1
|
|
return @{ $_[0]->{stop_ids} } |
|
|
0
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub stop_names { |
|
28
|
0
|
|
|
0
|
1
|
|
return @{ $_[0]->{stop_names} } |
|
|
0
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub stop_names_and_ids { |
|
32
|
0
|
|
|
0
|
1
|
|
my ( $self, $type ) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
0
|
|
|
|
$type ||= 'array'; |
|
35
|
0
|
0
|
|
|
|
|
$type = 'array' unless $type =~ /^(array|hash)$/; |
|
36
|
0
|
|
|
|
|
|
my @n = @{ $self->{stop_names} }; |
|
|
0
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my @i = @{ $self->{stop_ids} }; |
|
|
0
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $c = 0; |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return map { [ $_, $n[$c++] ] } @i |
|
|
0
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub get_schedule_by_stop_id { |
|
44
|
|
|
|
|
|
|
defined $_[0]->{map}{$_[1]} |
|
45
|
0
|
0
|
|
0
|
1
|
|
and return WWW::PTV::TimeTable::Schedule->new( $_[0]->{map}{$_[1]} ) |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub get_schedule_by_stop_name { |
|
49
|
0
|
|
|
0
|
1
|
|
my ( $self, $stop ) = @_; |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $c = 0; |
|
52
|
|
|
|
|
|
|
# This is really ugly - but we need to use the index of the matching |
|
53
|
|
|
|
|
|
|
# stop name as a hash key to retrieve the stop times from the map |
|
54
|
|
|
|
|
|
|
map { /$stop/i and return |
|
55
|
|
|
|
|
|
|
WWW::PTV::TimeTable::Schedule->new( |
|
56
|
0
|
0
|
|
|
|
|
$self->{map}{ @{ $self->{stop_ids} }[$c]} |
|
|
0
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
); |
|
58
|
0
|
|
|
|
|
|
$c++ |
|
59
|
0
|
|
|
|
|
|
} @{ $self->{stop_names} }; |
|
|
0
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub pretty_print { |
|
63
|
0
|
|
|
0
|
1
|
|
my $self= shift; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my @t = localtime(time); |
|
66
|
0
|
|
|
|
|
|
my @d = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday |
|
67
|
|
|
|
|
|
|
Sunday); |
|
68
|
0
|
|
|
|
|
|
my @m = qw(January February March April May June July August September |
|
69
|
|
|
|
|
|
|
October November December); |
|
70
|
0
|
|
|
|
|
|
printf("Current local time and date is: %s %s %s %02d:%02d %s\n", |
|
71
|
|
|
|
|
|
|
$d[$t[6]], $t[3], $m[$t[4]], $t[2], $t[1], ($t[5]+1900)); |
|
72
|
0
|
|
|
|
|
|
my $c = 0; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
foreach my $s ( @{ $self->{stop_times} } ) { |
|
|
0
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
printf( "| %-50s |", @{ $self->{stop_names} }[$c] ); |
|
|
0
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
map { |
|
78
|
0
|
|
|
|
|
|
printf( "%5s|", $_ ) |
|
79
|
0
|
|
|
|
|
|
} @{ @{ $self->{ stop_times } }[ $c ] }; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
print "\n+"; |
|
82
|
0
|
|
|
|
|
|
my $l = ( 54 + ( 7 * scalar @{ @{ $self->{stop_times} }[$c] } ) ) - 2; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
print "-"x$l; |
|
84
|
0
|
|
|
|
|
|
print "+\n"; |
|
85
|
0
|
|
|
|
|
|
$c++; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |