| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Travel::Status::DE::URA::Result; |
|
2
|
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
19
|
use strict; |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
140
|
|
|
4
|
5
|
|
|
5
|
|
20
|
use warnings; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
147
|
|
|
5
|
5
|
|
|
5
|
|
79
|
use 5.010; |
|
|
5
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
24
|
use parent 'Class::Accessor'; |
|
|
5
|
|
|
|
|
17
|
|
|
|
5
|
|
|
|
|
43
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
11867
|
use DateTime::Format::Duration; |
|
|
5
|
|
|
|
|
37793
|
|
|
|
5
|
|
|
|
|
2734
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '2.01'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Travel::Status::DE::URA::Result->mk_ro_accessors( |
|
14
|
|
|
|
|
|
|
qw(datetime destination line line_id stop stop_id stop_indicator)); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
|
17
|
33161
|
|
|
33161
|
1
|
160589
|
my ( $obj, %conf ) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
33161
|
|
|
|
|
33327
|
my $ref = \%conf; |
|
20
|
|
|
|
|
|
|
|
|
21
|
33161
|
|
|
|
|
109059
|
return bless( $ref, $obj ); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub countdown { |
|
25
|
2
|
|
|
2
|
1
|
543
|
my ($self) = @_; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$self->{countdown} //= $self->datetime->subtract_datetime( $self->{dt_now} ) |
|
28
|
2
|
|
66
|
|
|
17
|
->in_units('minutes'); |
|
29
|
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
533
|
return $self->{countdown}; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub countdown_sec { |
|
34
|
2
|
|
|
2
|
1
|
2
|
my ($self) = @_; |
|
35
|
2
|
|
|
|
|
15
|
my $secpattern = DateTime::Format::Duration->new( pattern => '%s' ); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->{countdown_sec} //= $secpattern->format_duration( |
|
38
|
2
|
|
66
|
|
|
93
|
$self->datetime->subtract_datetime( $self->{dt_now} ) ); |
|
39
|
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
394
|
return $self->{countdown_sec}; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub date { |
|
44
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
4
|
return $self->datetime->strftime('%d.%m.%Y'); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub platform { |
|
50
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
return $self->{stop_indicator}; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub time { |
|
56
|
1
|
|
|
1
|
1
|
816
|
my ($self) = @_; |
|
57
|
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
4
|
return $self->datetime->strftime('%H:%M:%S'); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub type { |
|
62
|
1
|
|
|
1
|
1
|
478
|
return 'Bus'; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub route_interesting { |
|
66
|
15
|
|
|
15
|
1
|
4381
|
my ( $self, $max_parts ) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
15
|
|
|
|
|
32
|
my @via = $self->route_post; |
|
69
|
15
|
|
|
|
|
26
|
my ( @via_main, @via_show, $last_stop ); |
|
70
|
15
|
|
100
|
|
|
42
|
$max_parts //= 3; |
|
71
|
|
|
|
|
|
|
|
|
72
|
15
|
|
|
|
|
16
|
for my $stop (@via) { |
|
73
|
660
|
100
|
|
|
|
4409
|
if ( |
|
74
|
|
|
|
|
|
|
$stop->name =~ m{ bf | hbf | Flughafen | bahnhof |
|
75
|
|
|
|
|
|
|
| Krankenhaus | Klinik | bushof | busstation }iox |
|
76
|
|
|
|
|
|
|
) |
|
77
|
|
|
|
|
|
|
{ |
|
78
|
30
|
|
|
|
|
189
|
push( @via_main, $stop ); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
} |
|
81
|
15
|
|
|
|
|
99
|
$last_stop = pop(@via); |
|
82
|
|
|
|
|
|
|
|
|
83
|
15
|
50
|
33
|
|
|
60
|
if ( @via_main and $via_main[-1] == $last_stop ) { |
|
84
|
0
|
|
|
|
|
0
|
pop(@via_main); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
15
|
50
|
33
|
|
|
47
|
if ( @via and $via[-1] == $last_stop ) { |
|
87
|
0
|
|
|
|
|
0
|
pop(@via); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
15
|
50
|
33
|
|
|
75
|
if ( @via_main and @via and $via[0] == $via_main[0] ) { |
|
|
|
|
33
|
|
|
|
|
|
91
|
0
|
|
|
|
|
0
|
shift(@via_main); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
15
|
50
|
|
|
|
25
|
if ( @via < $max_parts ) { |
|
95
|
0
|
|
|
|
|
0
|
@via_show = @via; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
else { |
|
98
|
15
|
100
|
|
|
|
23
|
if ( @via_main >= $max_parts ) { |
|
99
|
5
|
|
|
|
|
6
|
@via_show = ( $via[0] ); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
else { |
|
102
|
10
|
|
|
|
|
21
|
@via_show = splice( @via, 0, $max_parts - @via_main ); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
15
|
|
66
|
|
|
54
|
while ( @via_show < $max_parts and @via_main ) { |
|
106
|
23
|
|
|
|
|
19
|
my $stop = shift(@via_main); |
|
107
|
23
|
|
|
|
|
53
|
push( @via_show, $stop ); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
15
|
|
|
|
|
68
|
return @via_show; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub route_pre { |
|
115
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
|
116
|
|
|
|
|
|
|
|
|
117
|
1
|
|
|
|
|
1
|
return @{ $self->{route_pre} }; |
|
|
1
|
|
|
|
|
6
|
|
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub route_post { |
|
121
|
31
|
|
|
31
|
1
|
5582
|
my ($self) = @_; |
|
122
|
|
|
|
|
|
|
|
|
123
|
31
|
|
|
|
|
24
|
return @{ $self->{route_post} }; |
|
|
31
|
|
|
|
|
225
|
|
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub TO_JSON { |
|
127
|
8
|
|
|
8
|
1
|
2626
|
my ($self) = @_; |
|
128
|
|
|
|
|
|
|
|
|
129
|
8
|
|
|
|
|
9
|
return { %{$self} }; |
|
|
8
|
|
|
|
|
74
|
|
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
__END__ |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 NAME |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Travel::Status::DE::URA::Result - Information about a single |
|
139
|
|
|
|
|
|
|
departure received by Travel::Status::DE::URA |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
for my $departure ($status->results) { |
|
144
|
|
|
|
|
|
|
printf( |
|
145
|
|
|
|
|
|
|
"At %s: %s to %s (in %d minutes)", |
|
146
|
|
|
|
|
|
|
$departure->time, $departure->line, $departure->destination, |
|
147
|
|
|
|
|
|
|
$departure->countdown |
|
148
|
|
|
|
|
|
|
); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 VERSION |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
version 2.01 |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Travel::Status::DE::URA::Result describes a single departure as obtained by |
|
158
|
|
|
|
|
|
|
Travel::Status::DE::URA. It contains information about the time, |
|
159
|
|
|
|
|
|
|
line number and destination. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 METHODS |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 ACCESSORS |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=over |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item $departure->countdown |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Time in minutes from the time Travel::Status::DE::URA was instantiated until |
|
170
|
|
|
|
|
|
|
the bus will depart. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item $departure->countdown_sec |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Time in seconds from the time Travel::Status::DE::URA was instantiated until |
|
175
|
|
|
|
|
|
|
the bus will depart. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item $departure->date |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Departure date (DD.MM.YYYY) |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item $departure->datetime |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
DateTime object holding the departure date and time. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item $departure->destination |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Destination name. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item $departure->line |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
The name of the line. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item $departure->line_id |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
The number of the line. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item $departure->platform |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Shortcut for $departure->stop_indicator, see there. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item $departure->route_interesting(I<num_stops>) |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
If the B<results> method of Travel::Status::DE::URA(3pm) was called with |
|
204
|
|
|
|
|
|
|
B<calculate_routes> => true: Returns a list of up to I<num_stops> (defaults to |
|
205
|
|
|
|
|
|
|
3) stops considered interesting (usually of major importance in the transit |
|
206
|
|
|
|
|
|
|
area). Each stop is a Travel::Status::DE::URA::Stop(3pm) object. Note that the |
|
207
|
|
|
|
|
|
|
importance is determined heuristically based on the stop name, so it is not |
|
208
|
|
|
|
|
|
|
always accurate. |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Returns an empty list if B<calculate_routes> was false. |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item $departure->route_pre |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
If the B<results> method of Travel::Status::DE::URA(3pm) was called with |
|
215
|
|
|
|
|
|
|
B<calculate_routes> => true: |
|
216
|
|
|
|
|
|
|
Returns a list containing all stops after the requested one. |
|
217
|
|
|
|
|
|
|
Each stop is a Travel::Status::DE::URA::Stop(3pm) object. |
|
218
|
|
|
|
|
|
|
Returns an empty list otherwise. |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=item $departure->route_post |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Same as B<route_pre>, but contains the stops before the requested one. |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=item $departure->stop |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
The stop (name, not object) belonging to this departure. |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item $departure->stop_id |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
The stop ID belonging to this departure. |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item $departure->stop_indicator |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
The indicator for this departure at the corresponding stop, usually |
|
235
|
|
|
|
|
|
|
describes a platform or sub-stop number. undef if the stop does not |
|
236
|
|
|
|
|
|
|
have such a distinction. |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item $departure->time |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Departure time (HH:MM:SS). |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item $departure->type |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Vehicle type for this departure. At the moment, this always returns "Bus". |
|
245
|
|
|
|
|
|
|
This option exists for compatibility with other Travel::Status libraries. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=back |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head2 INTERNAL |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=over |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=item $departure = Travel::Status::DE::URA::Result->new(I<%data>) |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
Returns a new Travel::Status::DE::URA::Result object. You should not need to |
|
256
|
|
|
|
|
|
|
call this. |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=item $departure->TO_JSON |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Allows the object data to be serialized to JSON. |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=back |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
None. |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=over |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=item Class::Accessor(3pm) |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=back |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Unknown. |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Travel::Status::DE::URA(3pm), Travel::Status::DE::URA::Stop(3pm). |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head1 AUTHOR |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Copyright (C) 2013-2016 by Daniel Friesel E<lt>derf@finalrewind.orgE<gt> |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=head1 LICENSE |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
This module is licensed under the same terms as Perl itself. |