From c1d880d84e93d5c60098b2e3de909a950b78023c Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 4 Jan 2025 19:19:10 +0100 Subject: Departure: Add "id" accessor --- lib/Travel/Status/DE/EFA/Departure.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/Travel/Status/DE/EFA/Departure.pm') diff --git a/lib/Travel/Status/DE/EFA/Departure.pm b/lib/Travel/Status/DE/EFA/Departure.pm index e75ae07..fb7b374 100644 --- a/lib/Travel/Status/DE/EFA/Departure.pm +++ b/lib/Travel/Status/DE/EFA/Departure.pm @@ -167,6 +167,20 @@ sub parse_route { return \@ret; } +sub id { + my ($self) = @_; + + if ( $self->{id} ) { + return $self->{id}; + } + + return $self->{id} = sprintf( '%s@%d(%s)%d', + $self->stateless =~ s{ }{}gr, + scalar $self->route_pre ? ( $self->route_pre )[0]->id : $self->stop_id, + $self->sched_datetime->strftime('%Y%m%d'), + $self->key ); +} + sub hints { my ($self) = @_; @@ -324,6 +338,13 @@ Additional information related to the departure (list of strings). If departures for an address were requested, this is the stop name, otherwise it may be recent news related to the line's schedule. +=item $departure->id + +Stringified unique(?) identifier of this departure; suitable for passing to +Travel::Status::DE::EFA->new(stopseq) after decomposing it again. +The returned string combines B, B (or the ID of the first +stop in B, if present), B, and B. + =item $departure->is_cancelled 1 if the departure got cancelled, 0 otherwise. -- cgit v1.2.3