diff options
Diffstat (limited to 'lib/Travel/Status/DE/DBRIS')
-rw-r--r-- | lib/Travel/Status/DE/DBRIS/Journey.pm | 14 |
1 files changed, 13 insertions, 1 deletions
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) = @_; |