diff options
Diffstat (limited to 'lib/Travel/Status/DE/DBRIS/Journey.pm')
-rw-r--r-- | lib/Travel/Status/DE/DBRIS/Journey.pm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/DBRIS/Journey.pm b/lib/Travel/Status/DE/DBRIS/Journey.pm index 9c7d10c..ae4a0ee 100644 --- a/lib/Travel/Status/DE/DBRIS/Journey.pm +++ b/lib/Travel/Status/DE/DBRIS/Journey.pm @@ -11,7 +11,7 @@ use Travel::Status::DE::DBRIS::Location; our $VERSION = '0.07'; Travel::Status::DE::DBRIS::Journey->mk_ro_accessors( - qw(day train type number is_cancelled)); + qw(day id train type number is_cancelled)); sub new { my ( $obj, %opt ) = @_; @@ -21,6 +21,7 @@ sub new { my $strptime = $opt{strptime_obj}; my $ref = { + id => $opt{id}, day => $strpdate->parse_datetime( $json->{reisetag} ), train => $json->{zugName}, is_cancelled => $json->{cancelled}, @@ -33,6 +34,13 @@ sub new { # with no way of distinguishing between those ( $ref->{type}, $ref->{number} ) = split( qr{\s+}, $ref->{train} ); + # The line number seems to be encoded in the trip ID + if ( not defined $ref->{number} + and $opt{id} =~ m{ [#] ZE [#] (?<line> [^#]+ ) [#] ZB [#] }x ) + { + $ref->{number} = $+{line}; + } + bless( $ref, $obj ); for my $message ( @{ $json->{himMeldungen} // [] } ) { |