diff options
| -rw-r--r-- | lib/Travel/Status/DE/DBRIS/Formation/Carriage.pm | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/Travel/Status/DE/DBRIS/Formation/Carriage.pm b/lib/Travel/Status/DE/DBRIS/Formation/Carriage.pm index 3308efa..ab35906 100644 --- a/lib/Travel/Status/DE/DBRIS/Formation/Carriage.pm +++ b/lib/Travel/Status/DE/DBRIS/Formation/Carriage.pm @@ -83,14 +83,16 @@ sub new { $ref->{has_first_class} = $json{type}{hasFirstClass}; $ref->{has_second_class} = $json{type}{hasEconomyClass}; - if ( $ref->{type} =~ m{AB} ) { - $ref->{class_type} = 12; - } - elsif ( $ref->{type} =~ m{A} ) { - $ref->{class_type} = 1; - } - elsif ( $ref->{type} =~ m{B|WR} ) { - $ref->{class_type} = 2; + if ( $ref->{type} ) { + if ( $ref->{type} =~ m{AB} ) { + $ref->{class_type} = 12; + } + elsif ( $ref->{type} =~ m{A} ) { + $ref->{class_type} = 1; + } + elsif ( $ref->{type} =~ m{B|WR} ) { + $ref->{class_type} = 2; + } } my $pos = $json{platformPosition}; @@ -147,6 +149,11 @@ sub parse_type { my $type = $self->{type}; my @desc; + if ( not $type ) { + $self->{attributes} = []; + return; + } + if ( $type =~ m{^D} ) { $self->{is_dosto} = 1; push( @desc, 'Doppelstock' ); @@ -201,6 +208,9 @@ sub parse_type { sub is_first_class { my ($self) = @_; + if ( not defined $self->{type} ) { + return; + } if ( $self->{type} =~ m{^D?A} ) { return 1; } @@ -210,6 +220,9 @@ sub is_first_class { sub is_second_class { my ($self) = @_; + if ( not defined $self->{type} ) { + return; + } if ( $self->{type} =~ m{^D?A?B} ) { return 1; } |
