From 4604cbdbc219d7c42ea9b3f0e98208ae44527232 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 27 Jun 2015 10:55:42 +0200 Subject: aseag-m: clean up output code, improve route format --- bin/aseag-m | 66 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'bin') diff --git a/bin/aseag-m b/bin/aseag-m index a602052..529d9d1 100755 --- a/bin/aseag-m +++ b/bin/aseag-m @@ -87,7 +87,10 @@ sub display_result { printf( join( q{ }, @format ) . "\n", @{$line}[ 0 .. 2 ] ); if ($full_route) { - print "\n" . $line->[3] . "\n\n\n"; + for my $route ( @{ $line->[3] } ) { + printf( join( q{ }, @format ) . "\n", @{$route} ); + } + print "\n"; } } @@ -134,49 +137,46 @@ sub show_results { if ( ( @grep_lines and not( $d->line ~~ \@grep_lines ) ) ) { next; } + my @line; if ($relative_times) { - push( - @output, + @line = ( + $dt_format->format_duration( + $d->datetime->subtract_datetime($dt_now) + ), + $d->line, + $d->destination, [ - $dt_format->format_duration( - $d->datetime->subtract_datetime($dt_now) - ), - $d->line, - $d->destination, - join( - "\n", - map { - sprintf( - '%s %s', - $dt_format->format_duration( - $_->[0]->subtract_datetime($dt_now) - ), - $_->[1] - ) - } $d->route_timetable - ) + map { + [ + $dt_format->format_duration( + $_->[0]->subtract_datetime($dt_now) + ), + q{}, + $_->[1] + ] + } $d->route_timetable ] ); } else { - push( - @output, + @line = ( + $d->datetime->strftime($strftime_format), + $d->line, + $d->destination, [ - $d->datetime->strftime($strftime_format), - $d->line, - $d->destination, - join( - "\n", - map { - sprintf( '%s %s', - $_->[0]->strftime($strftime_format), - $_->[1] ) - } $d->route_timetable - ) + map { + [ $_->[0]->strftime($strftime_format), q{}, $_->[1] ] + } $d->route_timetable ] ); } + + if ( $full_route and $full_route eq 'before' ) { + @{ $line[3] } = reverse @{ $line[3] }; + } + + push( @output, \@line ); } display_result(@output); -- cgit v1.2.3