From c0e55de50c380638e0f3668cac79c58b4dccde10 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sun, 22 Sep 2024 15:19:21 +0200 Subject: add accessors for identified stop --- bin/efa-m | 9 +++++++++ lib/Travel/Status/DE/EFA.pm | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/bin/efa-m b/bin/efa-m index 7530326..3664325 100755 --- a/bin/efa-m +++ b/bin/efa-m @@ -290,6 +290,15 @@ sub show_results { $delay_fmt = $delay_len + 3; } + if ( scalar $efa->stops > 1 ) { + for my $stop ( $efa->stops ) { + say $stop->full_name; + } + } + else { + say $efa->stop_name; + } + for my $d ( $efa->results ) { my @output_line; diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm index ab029df..8774d59 100644 --- a/lib/Travel/Status/DE/EFA.pm +++ b/lib/Travel/Status/DE/EFA.pm @@ -346,6 +346,35 @@ sub check_for_ambiguous { return; } +sub stop_name { + my ($self) = @_; + + return $self->{response}{dm}{points}{point}{name}; +} + +sub stops { + my ($self) = @_; + + if ( $self->{stops} ) { + return @{ $self->{stops} }; + } + + my @stops; + for my $stop ( @{ $self->{response}{dm}{itdOdvAssignedStops} // [] } ) { + push( + @stops, + Travel::Status::DE::EFA::Stop->new( + place => $stop->{place}, + name => $stop->{name}, + full_name => $stop->{nameWithPlace}, + ) + ); + } + + $self->{stops} = \@stops; + return @stops; +} + sub lines { my ($self) = @_; -- cgit v1.2.3