diff options
| author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-11-23 18:58:07 +0100 |
|---|---|---|
| committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-11-23 18:58:07 +0100 |
| commit | 041239ed08399f6c87d3e33f49ff2216a0ff5232 (patch) | |
| tree | 848e3dda60aebc5457c4458ef7d2c0c1beaf69e2 /lib | |
| parent | b8b6eab04b7f4cb2286287551af228e56f2b02a5 (diff) | |
Journey: rename train, train_no to trip, trip_no
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Travel/Status/DE/DBRIS/Journey.pm | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/lib/Travel/Status/DE/DBRIS/Journey.pm b/lib/Travel/Status/DE/DBRIS/Journey.pm index 654bd11..8182a5f 100644 --- a/lib/Travel/Status/DE/DBRIS/Journey.pm +++ b/lib/Travel/Status/DE/DBRIS/Journey.pm @@ -12,10 +12,8 @@ use Travel::Status::DE::DBRIS::Operators; our $VERSION = '0.18'; # ->number is deprecated -# TODO: Rename ->train, ->train_no to ->trip, ->trip_no Travel::Status::DE::DBRIS::Journey->mk_ro_accessors( - qw(admin_id day id train train_no line_no type number operator is_cancelled) -); + qw(admin_id day id trip trip_no line_no type number operator is_cancelled)); sub new { my ( $obj, %opt ) = @_; @@ -27,7 +25,7 @@ sub new { my $ref = { id => $opt{id}, day => $strpdate->parse_datetime( $json->{reisetag} ), - train => $json->{zugName}, + trip => $json->{zugName}, is_cancelled => $json->{cancelled}, raw_route => $json->{halte}, raw_polyline => $json->{polylineGroup}{polylineDescriptions}, @@ -76,22 +74,22 @@ sub new { my @trip_no_argmax = reverse sort { $trip_no_ml{$a} <=> $trip_no_ml{$b} } keys %trip_no_ml; - $ref->{train_no} = $trip_no_argmax[0]; + $ref->{trip_no} = $trip_no_argmax[0]; $ref->{trip_numbers} = \@trip_no_argmax; } } # Number is either train no (ICE, RE) or line no (S, U, Bus, ...) # with no way of distinguishing between those - if ( $ref->{train} ) { - ( $ref->{type}, $ref->{number} ) = split( qr{\s+}, $ref->{train} ); + if ( $ref->{trip} ) { + ( $ref->{type}, $ref->{number} ) = split( qr{\s+}, $ref->{trip} ); } - # For some trains, the train type also contains the train number like "MEX19161" - # If we can detect this, remove the number from the train type - if ( $ref->{train_no} + # For some trips, the type also contains the trip number like "MEX19161" + # If we can detect this, remove the number from the trip type + if ( $ref->{trip_no} and $ref->{type} - and $ref->{type} =~ qr{ (?<actualtype> [^\d]+ ) $ref->{train_no} $ }x ) + and $ref->{type} =~ qr{ (?<actualtype> [^\d]+ ) $ref->{trip_no} $ }x ) { $ref->{type} = $+{actualtype}; } @@ -104,8 +102,8 @@ sub new { } if ( defined $ref->{number} - and defined $ref->{train_no} - and $ref->{number} ne $ref->{train_no} ) + and defined $ref->{trip_no} + and $ref->{number} ne $ref->{trip_no} ) { $ref->{line_no} = $ref->{number}; } @@ -246,6 +244,22 @@ sub trip_no_at { return; } +sub train { + my ($self) = @_; + + warn('$journey->train accessor is deprecated; use ->trip instead'); + + return $self->trip; +} + +sub train_no { + my ($self) = @_; + + warn('$journey->train_no accessor is deprecated; use ->trip_no instead'); + + return $self->trip_no; +} + sub TO_JSON { my ($self) = @_; |
