From d64dec80bc37609090b3f1ba3b253da5ed3c9bde Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 12 Oct 2015 13:33:09 +0200 Subject: return stop objects in route_interesting too --- Changelog | 4 ++-- bin/aseag-m | 2 +- lib/Travel/Status/DE/URA/Result.pm | 34 +++++++++++++++++----------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Changelog b/Changelog index d1ef69b..d3acd25 100644 --- a/Changelog +++ b/Changelog @@ -5,9 +5,9 @@ git HEAD * URA->new: Rename full_routes option to calculate_routes. The before/after parameters are no longer supported, instead any true parameter causes all routes to be calculated - * URA::Stop: Remove route_timetable accessor. Use route_pre / route_post + * URA::Result: Remove route_timetable accessor. Use route_pre / route_post instead - * Ura::Stop: Add route_pre, route_post and route_interesting accessors + * Ura::Result: Add route_pre, route_post and route_interesting accessors * new module: Travel::Status::DE::URA::Stop (describes a stop as a part of a departure's route) diff --git a/bin/aseag-m b/bin/aseag-m index 41bd188..86ed39a 100755 --- a/bin/aseag-m +++ b/bin/aseag-m @@ -209,7 +209,7 @@ sub show_results { } if ( $edata{route_interesting} ) { - $line[2] = join( q{ }, $d->route_interesting ); + $line[2] = join( q{ }, map { $_->name } $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 92be6c5..c0a1a21 100644 --- a/lib/Travel/Status/DE/URA/Result.pm +++ b/lib/Travel/Status/DE/URA/Result.pm @@ -59,14 +59,13 @@ sub type { sub route_interesting { my ( $self, $max_parts ) = @_; - my @via = map { $_->name } @{ $self->{route_post} }; - + my @via = $self->route_post; my ( @via_main, @via_show, $last_stop ); $max_parts //= 3; for my $stop (@via) { if ( - $stop =~ m{ bf | hbf | Flughafen | bahnhof + $stop->name =~ m{ bf | hbf | Flughafen | bahnhof | Krankenhaus | Klinik | bushof | busstation }iox ) { @@ -75,14 +74,14 @@ sub route_interesting { } $last_stop = pop(@via); - if ( @via_main and $via_main[-1] eq $last_stop ) { + if ( @via_main and $via_main[-1] == $last_stop ) { pop(@via_main); } - if ( @via and $via[-1] eq $last_stop ) { + if ( @via and $via[-1] == $last_stop ) { pop(@via); } - if ( @via_main and @via and $via[0] eq $via_main[0] ) { + if ( @via_main and @via and $via[0] == $via_main[0] ) { shift(@via_main); } @@ -192,20 +191,21 @@ The number of the line. =item $departure->route_interesting(I) If the B method of Travel::Status::DE::URA(3pm) was called with -B => true: -Returns up to I (defaults to 3) stops considered interesting -(usually of major importance in the transit area). Returns only stop names, -not the arrival/departure times. Note that the importance is determined -heuristically based on the stop name, so it is not always accurate. +B => true: Returns a list of up to I (defaults to +3) stops considered interesting (usually of major importance in the transit +area). Each stop is a Travel::Status::DE::URA::Stop(3pm) object. Note that the +importance is determined heuristically based on the stop name, so it is not +always accurate. + +Returns an empty list if B was false. =item $departure->route_pre If the B method of Travel::Status::DE::URA(3pm) was called with B => true: -Returns a list of arrayrefs describing all stops after the requested one. I.e. -C<< ([$time1, $stop1], [$time2, $stop2], ...) >>. -The times are DateTime::Duration(3pm) objects, the stops are only names, -not IDs (subject to change). Returns an empty list otherwise. +Returns a list containing all stops after the requested one. +Each stop is a Travel::Status::DE::URA::Stop(3pm) object. +Returns an empty list otherwise. =item $departure->route_post @@ -213,7 +213,7 @@ Same as B, but contains the stops before the requested one. =item $departure->stop -The stop belonging to this departure. +The stop (name, not object) belonging to this departure. =item $departure->stop_id @@ -263,7 +263,7 @@ Unknown. =head1 SEE ALSO -Travel::Status::DE::URA(3pm). +Travel::Status::DE::URA(3pm), Travel::Status::DE::URA::Stop(3pm). =head1 AUTHOR -- cgit v1.2.3