line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Travel::Status::DE::EFA::Result; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
62
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
72
|
|
5
|
2
|
|
|
2
|
|
37
|
use 5.010; |
|
2
|
|
|
|
|
9
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
12
|
use parent 'Class::Accessor'; |
|
2
|
|
|
|
|
26
|
|
|
2
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.22'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Travel::Status::DE::EFA::Result->mk_ro_accessors( |
12
|
|
|
|
|
|
|
qw(countdown date delay destination is_cancelled info key line lineref |
13
|
|
|
|
|
|
|
mot occupancy operator platform platform_db platform_name sched_date sched_time time train_no type) |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @mot_mapping = qw{ |
17
|
|
|
|
|
|
|
zug s-bahn u-bahn stadtbahn tram stadtbus regionalbus |
18
|
|
|
|
|
|
|
schnellbus seilbahn schiff ast sonstige |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
40
|
|
|
40
|
1
|
434
|
my ( $obj, %conf ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
40
|
|
|
|
|
79
|
my $ref = \%conf; |
25
|
|
|
|
|
|
|
|
26
|
40
|
50
|
66
|
|
|
120
|
if ( defined $ref->{delay} and $ref->{delay} eq '-9999' ) { |
27
|
0
|
|
|
|
|
0
|
$ref->{delay} = 0; |
28
|
0
|
|
|
|
|
0
|
$ref->{is_cancelled} = 1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
40
|
|
|
|
|
64
|
$ref->{is_cancelled} = 0; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
40
|
|
|
|
|
219
|
return bless( $ref, $obj ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub mot_name { |
38
|
3
|
|
|
3
|
1
|
57806
|
my ($self) = @_; |
39
|
|
|
|
|
|
|
|
40
|
3
|
|
50
|
|
|
29
|
return $mot_mapping[ $self->{mot} ] // 'sonstige'; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub route_pre { |
44
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return @{ $self->{prev_route} }; |
|
0
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub route_post { |
50
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return @{ $self->{next_route} }; |
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub route_interesting { |
56
|
0
|
|
|
0
|
1
|
|
my ( $self, $max_parts ) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my @via = $self->route_post; |
59
|
0
|
|
|
|
|
|
my ( @via_main, @via_show, $last_stop ); |
60
|
0
|
|
0
|
|
|
|
$max_parts //= 3; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
for my $stop (@via) { |
63
|
0
|
0
|
|
|
|
|
if ( |
64
|
|
|
|
|
|
|
$stop->name_suf =~ m{ Bf | Hbf | Flughafen | Hauptbahnhof |
65
|
|
|
|
|
|
|
| Krankenhaus | Klinik | (?: S $ ) }ox |
66
|
|
|
|
|
|
|
) |
67
|
|
|
|
|
|
|
{ |
68
|
0
|
|
|
|
|
|
push( @via_main, $stop ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
$last_stop = pop(@via); |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
0
|
|
|
|
if ( @via_main and $via_main[-1] == $last_stop ) { |
74
|
0
|
|
|
|
|
|
pop(@via_main); |
75
|
|
|
|
|
|
|
} |
76
|
0
|
0
|
0
|
|
|
|
if ( @via and $via[-1] == $last_stop ) { |
77
|
0
|
|
|
|
|
|
pop(@via); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
0
|
|
|
|
if ( @via_main and @via and $via[0] == $via_main[0] ) { |
|
|
|
0
|
|
|
|
|
81
|
0
|
|
|
|
|
|
shift(@via_main); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
if ( @via < $max_parts ) { |
85
|
0
|
|
|
|
|
|
@via_show = @via; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
0
|
0
|
|
|
|
|
if ( @via_main >= $max_parts ) { |
89
|
0
|
|
|
|
|
|
@via_show = ( $via[0] ); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else { |
92
|
0
|
|
|
|
|
|
@via_show = splice( @via, 0, $max_parts - @via_main ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
0
|
|
|
|
while ( @via_show < $max_parts and @via_main ) { |
96
|
0
|
|
|
|
|
|
my $stop = shift(@via_main); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# FIXME cannot smartmatch $stop since it became an object |
99
|
|
|
|
|
|
|
# if ( $stop ~~ \@via_show or $stop == $last_stop ) { |
100
|
|
|
|
|
|
|
# next; |
101
|
|
|
|
|
|
|
# } |
102
|
0
|
|
|
|
|
|
push( @via_show, $stop ); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
return @via_show; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub TO_JSON { |
110
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
return { %{$self} }; |
|
0
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
__END__ |