diff options
author | Daniel Friesel <derf@finalrewind.org> | 2013-10-16 18:32:50 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2013-10-16 18:32:50 +0200 |
commit | 565b081d49fee46f8ffd830057b1939286f3551b (patch) | |
tree | 879c22b20acb19f3e0bc772fc835758a4d4f854e | |
parent | 585a0f6f476ec04f19e2924dbbcbd898343cc867 (diff) |
add $result->is_cancelled accessor, do not allow delay == -9999
-rw-r--r-- | Changelog | 3 | ||||
-rwxr-xr-x | bin/efa-m | 10 | ||||
-rw-r--r-- | lib/Travel/Status/DE/VRR/Result.pm | 20 |
3 files changed, 22 insertions, 11 deletions
@@ -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) @@ -136,13 +136,11 @@ sub show_results { next; } + if ( $d->is_cancelled ) { + $dtime .= ' CANCELED'; + } if ( $d->delay ) { - if ($d->delay eq '-9999') { - $dtime .= ' CANCELED'; - } - else { - $dtime .= ' (+' . $d->delay . ')'; - } + $dtime .= ' (+' . $d->delay . ')'; } push( @output, 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 |