Unverified Commit c1d880d8 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Departure: Add "id" accessor

parent a92a2b0d
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -483,11 +483,7 @@ sub show_results {
		@output_line = ( $dtime, $platform, $line, q{}, $d->destination, $d );

		if ($show_jid) {
			$output_line[2] .= sprintf( '  %s@%d(%s)%d',
				$d->stateless =~ s{ }{}gr,
				scalar $d->route_pre ? ( $d->route_pre )[0]->id : $d->stop_id,
				$d->sched_datetime->strftime('%Y%m%d'),
				$d->key );
			$output_line[2] .= '  ' . $d->id;
		}

		if ( $edata{route} ) {
+21 −0
Original line number Diff line number Diff line
@@ -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.