diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2024-09-22 13:19:14 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2024-09-22 13:19:14 +0200 |
commit | c438b3c4e210a4480652f297f1bf9510cdf44244 (patch) | |
tree | 2b2445ecba473799c3ebed1f7b8b1210084f29bc /lib/Travel/Status/DE/EFA | |
parent | b8bdca3c045787ad546234fff0cf5801dbe1cd92 (diff) |
Switch from XML to JSON API flavour
Diffstat (limited to 'lib/Travel/Status/DE/EFA')
-rw-r--r-- | lib/Travel/Status/DE/EFA/Departure.pm (renamed from lib/Travel/Status/DE/EFA/Result.pm) | 41 | ||||
-rw-r--r-- | lib/Travel/Status/DE/EFA/Line.pm | 2 |
2 files changed, 26 insertions, 17 deletions
diff --git a/lib/Travel/Status/DE/EFA/Result.pm b/lib/Travel/Status/DE/EFA/Departure.pm index 11ff15a..802f84e 100644 --- a/lib/Travel/Status/DE/EFA/Result.pm +++ b/lib/Travel/Status/DE/EFA/Departure.pm @@ -1,4 +1,4 @@ -package Travel::Status::DE::EFA::Result; +package Travel::Status::DE::EFA::Departure; use strict; use warnings; @@ -8,10 +8,10 @@ use parent 'Class::Accessor'; our $VERSION = '2.02'; -Travel::Status::DE::EFA::Result->mk_ro_accessors( - qw(countdown datetime delay destination is_cancelled info key line lineref - mot occupancy operator platform platform_db platform_name rt_datetime - sched_datetime train_type train_name train_no type) +Travel::Status::DE::EFA::Departure->mk_ro_accessors( + qw(countdown datetime delay destination is_cancelled key line lineref + mot occupancy operator origin platform platform_db platform_name + rt_datetime sched_datetime train_type train_name train_no type) ); my @mot_mapping = qw{ @@ -37,6 +37,12 @@ sub new { return bless( $ref, $obj ); } +sub hints { + my ($self) = @_; + + return @{ $self->{hints} // [] }; +} + sub mot_name { my ($self) = @_; @@ -46,13 +52,13 @@ sub mot_name { sub route_pre { my ($self) = @_; - return @{ $self->{prev_route} }; + return @{ $self->{prev_route} // [] }; } sub route_post { my ($self) = @_; - return @{ $self->{next_route} }; + return @{ $self->{next_route} // [] }; } sub route_interesting { @@ -121,7 +127,7 @@ __END__ =head1 NAME -Travel::Status::DE::EFA::Result - Information about a single +Travel::Status::DE::EFA::Departure - Information about a single departure received by Travel::Status::DE::EFA =head1 SYNOPSIS @@ -140,7 +146,7 @@ version 2.02 =head1 DESCRIPTION -Travel::Status::DE::EFA::Result describes a single departure as obtained by +Travel::Status::DE::EFA::Departure describes a single departure as obtained by Travel::Status::DE::EFA. It contains information about the time, platform, line number and destination. @@ -171,12 +177,11 @@ indicates departure on time. undef when no realtime information is available. Destination name. -=item $departure->info +=item $departure->hints -Additional information related to the departure (string). If departures for -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. +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->is_cancelled @@ -216,6 +221,10 @@ Occupancy values are passed from the backend as-is. Known values are "MANY_SEATS" (low occupation), "FEW_SEATS" (high occupation), "STANDING_ONLY" (very high occupation), and "FULL" (boarding not advised). +=item $departure->origin + +Origin name. + =item $departure->platform Departure platform number (may not be a number). @@ -277,9 +286,9 @@ field. See L</DEPARTURE TYPES>. =over -=item $departure = Travel::Status::DE::EFA::Result->new(I<%data>) +=item $departure = Travel::Status::DE::EFA::Departure->new(I<%data>) -Returns a new Travel::Status::DE::EFA::Result object. You should not need to +Returns a new Travel::Status::DE::EFA::Departure object. You should not need to call this. =item $departure->TO_JSON diff --git a/lib/Travel/Status/DE/EFA/Line.pm b/lib/Travel/Status/DE/EFA/Line.pm index 69526fd..4f44c7b 100644 --- a/lib/Travel/Status/DE/EFA/Line.pm +++ b/lib/Travel/Status/DE/EFA/Line.pm @@ -9,7 +9,7 @@ use parent 'Class::Accessor'; our $VERSION = '2.02'; Travel::Status::DE::EFA::Line->mk_ro_accessors( - qw(direction mot name operator route type valid)); + qw(direction mot name number operator route type valid)); my @mot_mapping = qw{ zug s-bahn u-bahn stadtbahn tram stadtbus regionalbus |