line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Travel::Status::DE::URA::Result; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
16
|
use strict; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
118
|
|
4
|
5
|
|
|
5
|
|
16
|
use warnings; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
110
|
|
5
|
5
|
|
|
5
|
|
71
|
use 5.010; |
|
5
|
|
|
|
|
12
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
16
|
use parent 'Class::Accessor'; |
|
5
|
|
|
|
|
4
|
|
|
5
|
|
|
|
|
32
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
10827
|
use DateTime::Format::Duration; |
|
5
|
|
|
|
|
19778
|
|
|
5
|
|
|
|
|
2359
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
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
|
147207
|
my ( $obj, %conf ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
33161
|
|
|
|
|
29062
|
my $ref = \%conf; |
20
|
|
|
|
|
|
|
|
21
|
33161
|
|
|
|
|
102684
|
return bless( $ref, $obj ); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub countdown { |
25
|
2
|
|
|
2
|
1
|
540
|
my ($self) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$self->{countdown} //= $self->datetime->subtract_datetime( $self->{dt_now} ) |
28
|
2
|
|
66
|
|
|
20
|
->in_units('minutes'); |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
542
|
return $self->{countdown}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub countdown_sec { |
34
|
2
|
|
|
2
|
1
|
5
|
my ($self) = @_; |
35
|
2
|
|
|
|
|
13
|
my $secpattern = DateTime::Format::Duration->new( pattern => '%s' ); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->{countdown_sec} //= $secpattern->format_duration( |
38
|
2
|
|
66
|
|
|
70
|
$self->datetime->subtract_datetime( $self->{dt_now} ) ); |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
368
|
return $self->{countdown_sec}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub date { |
44
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
8
|
return $self->datetime->strftime('%d.%m.%Y'); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub time { |
50
|
1
|
|
|
1
|
1
|
711
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
4
|
return $self->datetime->strftime('%H:%M:%S'); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub type { |
56
|
1
|
|
|
1
|
1
|
397
|
return 'Bus'; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub route_interesting { |
60
|
15
|
|
|
15
|
1
|
2443
|
my ( $self, $max_parts ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
15
|
|
|
|
|
22
|
my @via = $self->route_post; |
63
|
15
|
|
|
|
|
21
|
my ( @via_main, @via_show, $last_stop ); |
64
|
15
|
|
100
|
|
|
37
|
$max_parts //= 3; |
65
|
|
|
|
|
|
|
|
66
|
15
|
|
|
|
|
19
|
for my $stop (@via) { |
67
|
660
|
100
|
|
|
|
4391
|
if ( |
68
|
|
|
|
|
|
|
$stop->name =~ m{ bf | hbf | Flughafen | bahnhof |
69
|
|
|
|
|
|
|
| Krankenhaus | Klinik | bushof | busstation }iox |
70
|
|
|
|
|
|
|
) |
71
|
|
|
|
|
|
|
{ |
72
|
30
|
|
|
|
|
196
|
push( @via_main, $stop ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
15
|
|
|
|
|
93
|
$last_stop = pop(@via); |
76
|
|
|
|
|
|
|
|
77
|
15
|
50
|
33
|
|
|
62
|
if ( @via_main and $via_main[-1] == $last_stop ) { |
78
|
0
|
|
|
|
|
0
|
pop(@via_main); |
79
|
|
|
|
|
|
|
} |
80
|
15
|
50
|
33
|
|
|
42
|
if ( @via and $via[-1] == $last_stop ) { |
81
|
0
|
|
|
|
|
0
|
pop(@via); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
15
|
50
|
33
|
|
|
69
|
if ( @via_main and @via and $via[0] == $via_main[0] ) { |
|
|
|
33
|
|
|
|
|
85
|
0
|
|
|
|
|
0
|
shift(@via_main); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
15
|
50
|
|
|
|
23
|
if ( @via < $max_parts ) { |
89
|
0
|
|
|
|
|
0
|
@via_show = @via; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else { |
92
|
15
|
100
|
|
|
|
18
|
if ( @via_main >= $max_parts ) { |
93
|
5
|
|
|
|
|
8
|
@via_show = ( $via[0] ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
else { |
96
|
10
|
|
|
|
|
20
|
@via_show = splice( @via, 0, $max_parts - @via_main ); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
15
|
|
66
|
|
|
50
|
while ( @via_show < $max_parts and @via_main ) { |
100
|
23
|
|
|
|
|
18
|
my $stop = shift(@via_main); |
101
|
23
|
|
|
|
|
48
|
push( @via_show, $stop ); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
15
|
|
|
|
|
64
|
return @via_show; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub route_pre { |
109
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
2
|
return @{ $self->{route_pre} }; |
|
1
|
|
|
|
|
5
|
|
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub route_post { |
115
|
31
|
|
|
31
|
1
|
3251
|
my ($self) = @_; |
116
|
|
|
|
|
|
|
|
117
|
31
|
|
|
|
|
65
|
return @{ $self->{route_post} }; |
|
31
|
|
|
|
|
186
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub TO_JSON { |
121
|
8
|
|
|
8
|
1
|
2197
|
my ($self) = @_; |
122
|
|
|
|
|
|
|
|
123
|
8
|
|
|
|
|
8
|
return { %{$self} }; |
|
8
|
|
|
|
|
77
|
|
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__ |