summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-04-15 19:37:03 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-04-15 19:37:03 +0200
commit33af8b700e663a0d65e9bc761077d08fd79e98dc (patch)
treeb4eeee5336f2826cc9fb978ef8c280db788e7360
parent67d6cd7078e51490176c14427a4f7eb339925e2f (diff)
Journey: Add product_at accessor
-rw-r--r--lib/Travel/Status/DE/HAFAS/Journey.pm18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Journey.pm b/lib/Travel/Status/DE/HAFAS/Journey.pm
index 978268e..696841e 100644
--- a/lib/Travel/Status/DE/HAFAS/Journey.pm
+++ b/lib/Travel/Status/DE/HAFAS/Journey.pm
@@ -17,7 +17,7 @@ Travel::Status::DE::HAFAS::Journey->mk_ro_accessors(
qw(datetime sched_datetime rt_datetime tz_offset
is_additional is_cancelled is_partially_cancelled
station station_eva platform sched_platform rt_platform operator
- product
+ product product_at
id name type type_long class number line line_no load delay
route_end route_start origin destination direction)
);
@@ -368,6 +368,16 @@ sub route_interesting {
}
+sub product_at {
+ my ( $self, $req_stop ) = @_;
+ for my $stop ( $self->route ) {
+ if ( $stop->loc->name eq $req_stop or $stop->loc->eva eq $req_stop ) {
+ return $stop->prod_dep // $stop->prod_arr;
+ }
+ }
+ return;
+}
+
sub TO_JSON {
my ($self) = @_;
@@ -530,6 +540,12 @@ of transport, line number / ID, operator, ...) associated with this journey.
Note that journeys may be associated with multiple products -- see also
C<< $journey->route >> and C<< $stop->product >>.
+=item $journey->product_at(I<stop>)
+
+Travel::Status::DE::HAFAS::Product(3pm) instance describing the product
+associated with I<stop> (name or EVA ID). Returns undef if product or I<stop>
+are unknown.
+
=item $journey->rt_platform (station only)
Actual arrival/departure platform.