summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/EFA/Departure.pm
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-01-04 19:19:10 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2025-01-04 19:19:10 +0100
commitc1d880d84e93d5c60098b2e3de909a950b78023c (patch)
treeec0ef38bab0d6297e30c62cabb5eca176d047eda /lib/Travel/Status/DE/EFA/Departure.pm
parenta92a2b0d5583114cd3d86660af6a81f19223b003 (diff)
Departure: Add "id" accessor
Diffstat (limited to 'lib/Travel/Status/DE/EFA/Departure.pm')
-rw-r--r--lib/Travel/Status/DE/EFA/Departure.pm21
1 files changed, 21 insertions, 0 deletions
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<stateless>, B<stop_id> (or the ID of the first
+stop in B<route_pre>, if present), B<sched_datetime>, and B<key>.
+
=item $departure->is_cancelled
1 if the departure got cancelled, 0 otherwise.