diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2024-12-14 22:22:38 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2024-12-14 22:22:38 +0100 |
commit | 87637c4f37a798718e75b5b9d7fb08a6fc606349 (patch) | |
tree | e13dcc70a25b6091e39325141a595de4b81ba9fd /lib/Travel/Status/DE/DBRIS.pm | |
parent | 091f9fa04b5a44e8ccecc65b0dc22dc0d12a94d2 (diff) |
add preliminary departure board support
Diffstat (limited to 'lib/Travel/Status/DE/DBRIS.pm')
-rw-r--r-- | lib/Travel/Status/DE/DBRIS.pm | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/Travel/Status/DE/DBRIS.pm b/lib/Travel/Status/DE/DBRIS.pm index 2b19924..a2bf311 100644 --- a/lib/Travel/Status/DE/DBRIS.pm +++ b/lib/Travel/Status/DE/DBRIS.pm @@ -13,6 +13,7 @@ use DateTime::Format::Strptime; use Encode qw(decode encode); use JSON; use LWP::UserAgent; +use Travel::Status::DE::DBRIS::Journey; use Travel::Status::DE::DBRIS::Location; our $VERSION = '0.01'; @@ -67,10 +68,10 @@ sub new { confess('station or geoSearch must be specified'); } - #$self->{strptime_obj} //= DateTime::Format::Strptime->new( - # pattern => '%Y%m%dT%H%M%S', - # time_zone => $hafas_instance->{$service}{time_zone} // 'Europe/Berlin', - #); + $self->{strptime_obj} //= DateTime::Format::Strptime->new( + pattern => '%Y-%m-%dT%H:%M:%S%Z', + time_zone => 'Europe/Berlin', + ); my $json = $self->{json} = JSON->new->utf8; @@ -244,12 +245,6 @@ sub get_with_cache_p { sub parse_search { my ($self) = @_; - $self->{results} = []; - - if ( $self->{errstr} ) { - return $self; - } - @{ $self->{results} } = map { Travel::Status::DE::DBRIS::Location->new( json => $_ ) } @{ $self->{raw_json} // [] }; @@ -257,6 +252,21 @@ sub parse_search { return $self; } +sub parse_stationboard { + my ($self) = @_; + + # @{$self->{messages}} = map { Travel::Status::DE::DBRIS::Message->new(...) } @{$self->{raw_json}{globalMessages}/[]}; + + @{ $self->{results} } = map { + Travel::Status::DE::DBRIS::Journey->new( + json => $_, + strptime_obj => $self->{strptime_obj} + ) + } @{ $self->{raw_json}{entries} // [] }; + + return $self; +} + # }}} # {{{ Public Functions |