Unverified Commit c2bf7522 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Carriage: handle undefined values

parent b9e67e40
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ sub new {
	$ref->{has_first_class}  = $json{type}{hasFirstClass};
	$ref->{has_second_class} = $json{type}{hasEconomyClass};

	if ( $ref->{type} ) {
		if ( $ref->{type} =~ m{AB} ) {
			$ref->{class_type} = 12;
		}
@@ -92,6 +93,7 @@ sub new {
		elsif ( $ref->{type} =~ m{B|WR} ) {
			$ref->{class_type} = 2;
		}
	}

	my $pos             = $json{platformPosition};
	my $platform_length = $platform->{end} - $platform->{start};
@@ -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;
	}