From 7caeab689baf8390e12915264838c1a0da73e2ef Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Thu, 26 Dec 2024 14:00:54 +0100 Subject: journey: parse trip day and attributes --- lib/Travel/Status/DE/DBRIS/Journey.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/Travel/Status/DE/DBRIS') diff --git a/lib/Travel/Status/DE/DBRIS/Journey.pm b/lib/Travel/Status/DE/DBRIS/Journey.pm index c4f7df6..4900809 100644 --- a/lib/Travel/Status/DE/DBRIS/Journey.pm +++ b/lib/Travel/Status/DE/DBRIS/Journey.pm @@ -10,15 +10,17 @@ use Travel::Status::DE::DBRIS::Location; our $VERSION = '0.01'; -Travel::Status::DE::DBRIS::Journey->mk_ro_accessors(qw(train is_cancelled)); +Travel::Status::DE::DBRIS::Journey->mk_ro_accessors(qw(day train is_cancelled)); sub new { my ( $obj, %opt ) = @_; my $json = $opt{json}; + my $strpdate = $opt{strpdate_obj}; my $strptime = $opt{strptime_obj}; my $ref = { + day => $strpdate->parse_datetime( $json->{reisetag} ), train => $json->{zugName}, is_cancelled => $json->{cancelled}, raw_route => $json->{halte}, @@ -31,6 +33,10 @@ sub new { push( @{ $ref->{messages} }, $message ); } + for my $attr ( @{ $json->{zugattribute} // [] } ) { + push( @{ $ref->{attributes} }, $attr ); + } + return $ref; } @@ -53,6 +59,12 @@ sub route { return @{ $self->{route} }; } +sub attributes { + my ($self) = @_; + + return @{ $self->{attributes} // [] }; +} + sub messages { my ($self) = @_; -- cgit v1.2.3