Commit 565b081d authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

add $result->is_cancelled accessor, do not allow delay == -9999

parent 585a0f6f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@ git HEAD

    * Add ->key accessor to Travel::Status::DE::VRR::Line
      (meaning is unknown)
    * Add ->is_cancelled accessor to Travel::Status::DE::VRR::Result
    * Travel::Status::DE::VRR::Result->delay will no longer return '-9999'
      for cancelled departures, check ->is_cancelled instead
    * Allow Travel::Status::DE::VRR::Line and TraveL::Status::DE::VRR::Result
      to be serialized to JSON (via TO_JSON method)

+4 −6
Original line number Diff line number Diff line
@@ -136,14 +136,12 @@ sub show_results {
			next;
		}

		if ( $d->delay ) {
			if ($d->delay eq '-9999') {
		if ( $d->is_cancelled ) {
			$dtime .= ' CANCELED';
		}
			else {
		if ( $d->delay ) {
			$dtime .= ' (+' . $d->delay . ')';
		}
		}

		push( @output,
			[ $dtime, $platform, $d->line, $d->destination, $d->info ] );
+15 −5
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ use parent 'Class::Accessor';
our $VERSION = '1.03';

Travel::Status::DE::VRR::Result->mk_ro_accessors(
	qw(countdown date delay destination info key line lineref platform
	qw(countdown date delay destination is_cancelled info key line lineref platform
	  platform_db sched_date sched_time time type)
);

@@ -18,6 +18,14 @@ sub new {

	my $ref = \%conf;

	if ($ref->{delay} eq '-9999') {
		$ref->{delay} = 0;
		$ref->{is_cancelled} = 1;
	}
	else {
		$ref->{is_cancelled} = 0;
	}

	return bless( $ref, $obj );
}

@@ -77,10 +85,8 @@ Actual departure date (DD.MM.YYYY).

=item $departure->delay

Expected delay from scheduled departure time in minutes.

Note that this is only available for DB trains, in other cases it will always
return 0.
Expected delay from scheduled departure time in minutes. A delay of 0
indicates either departure on time or that no delay information is available.

=item $departure->destination

@@ -93,6 +99,10 @@ an address were requested, this is the stop name, otherwise it may be recent
news related to the line's schedule.  If no information is available, returns
an empty string.

=item $departure->is_cancelled

1 if the departure got cancelled, 0 otherwise.

=item $departure->key

Unknown.  Unlike the name may suggest, this is not a unique key / UUID for a