From 565b081d49fee46f8ffd830057b1939286f3551b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 16 Oct 2013 18:32:50 +0200 Subject: add $result->is_cancelled accessor, do not allow delay == -9999 --- lib/Travel/Status/DE/VRR/Result.pm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'lib/Travel/Status') diff --git a/lib/Travel/Status/DE/VRR/Result.pm b/lib/Travel/Status/DE/VRR/Result.pm index e1ebee5..0468115 100644 --- a/lib/Travel/Status/DE/VRR/Result.pm +++ b/lib/Travel/Status/DE/VRR/Result.pm @@ -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 -- cgit v1.2.3