diff options
author | Daniel Friesel <derf@finalrewind.org> | 2015-10-07 18:29:12 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2015-10-07 18:29:12 +0200 |
commit | e0845072109fce647b5b61076f8bba978d3adf65 (patch) | |
tree | 98b308ac86184f774c32bca0c885c2ae3e2b0197 | |
parent | d35b36d0b81c12fbb828a59f2305e491306b9840 (diff) |
route_interesting support in aseag-m
-rwxr-xr-x | bin/aseag-m | 30 | ||||
-rw-r--r-- | lib/Travel/Status/DE/URA/Result.pm | 10 |
2 files changed, 23 insertions, 17 deletions
diff --git a/bin/aseag-m b/bin/aseag-m index 22303a6..7edb7d6 100755 --- a/bin/aseag-m +++ b/bin/aseag-m @@ -45,11 +45,12 @@ if ( @ARGV != 1 ) { for my $efield (@edata_pre) { given ($efield) { - when ('a') { $edata{route_after} = 1; $calculate_routes = 1 } - when ('b') { $edata{route_before} = 1; $calculate_routes = 1 } - when ('f') { $edata{route_full} = 1; $calculate_routes = 1 } - when ('T') { $edata{relative_times} = 1 } - default { $edata{$efield} = 1 } + when ('a') { $edata{route_after} = 1; $calculate_routes = 1 } + when ('b') { $edata{route_before} = 1; $calculate_routes = 1 } + when ('f') { $edata{route_full} = 1; $calculate_routes = 1 } + when ('r') { $edata{route_interesting} = 1; $calculate_routes = 1 } + when ('T') { $edata{relative_times} = 1 } + default { $edata{$efield} = 1 } } } @@ -76,7 +77,7 @@ sub show_version { sub display_result { my (@lines) = @_; - my @format = qw(%- %- %-); + my @format = qw(%- %- %- %-); if ( not @lines ) { die("Nothing to show\n"); @@ -86,17 +87,17 @@ sub display_result { $format[0] = q{%}; } - for my $i ( 0 .. 2 ) { + for my $i ( 0 .. 3 ) { $format[$i] .= max map { length( $_->[$i] ) } @lines; $format[$i] .= 's'; } for my $line (@lines) { - printf( join( q{ }, @format ) . "\n", @{$line}[ 0 .. 2 ] ); + printf( join( q{ }, @format ) . "\n", @{$line}[ 0 .. 3 ] ); - if ( @{ $line->[3] } ) { - for my $route ( @{ $line->[3] } ) { + if ( @{ $line->[4] } ) { + for my $route ( @{ $line->[4] } ) { printf( join( q{ }, @format ) . "\n", @{$route} ); } print "\n"; @@ -188,6 +189,7 @@ sub show_results { $d->datetime->subtract_datetime($dt_now) ), $d->line, + q{}, $d->destination, [ show_route( $dt_now, $dt_format, @route ) ], ); @@ -195,13 +197,17 @@ sub show_results { else { @line = ( $d->datetime->strftime($strftime_format), - $d->line, $d->destination, + $d->line, q{}, $d->destination, [ show_route( $dt_now, $dt_format, @route ) ], ); } if ( $edata{route_before} ) { - @{ $line[3] } = reverse @{ $line[3] }; + @{ $line[4] } = reverse @{ $line[4] }; + } + + if ( $edata{route_interesting} ) { + $line[2] = join( q{ }, $d->route_interesting ); } push( @output, \@line ); diff --git a/lib/Travel/Status/DE/URA/Result.pm b/lib/Travel/Status/DE/URA/Result.pm index fe6b75e..f59ba8e 100644 --- a/lib/Travel/Status/DE/URA/Result.pm +++ b/lib/Travel/Status/DE/URA/Result.pm @@ -59,14 +59,14 @@ sub type { sub route_interesting { my ( $self, $max_parts ) = @_; - my @via = map { $_->[1] } @{ $self->{route_timetable} }; + my @via = map { $_->[1] } @{ $self->{route_post} }; my ( @via_main, @via_show, $last_stop ); $max_parts //= 3; for my $stop (@via) { if ( - $stop->name_suf =~ m{ bf | hbf | Flughafen | bahnhof + $stop =~ m{ bf | hbf | Flughafen | bahnhof | Krankenhaus | Klinik | bushof | busstation }iox ) { @@ -75,14 +75,14 @@ sub route_interesting { } $last_stop = pop(@via); - if ( @via_main and $via_main[-1] == $last_stop ) { + if ( @via_main and $via_main[-1] eq $last_stop ) { pop(@via_main); } - if ( @via and $via[-1] == $last_stop ) { + if ( @via and $via[-1] eq $last_stop ) { pop(@via); } - if ( @via_main and @via and $via[0] == $via_main[0] ) { + if ( @via_main and @via and $via[0] eq $via_main[0] ) { shift(@via_main); } |