Loading lib/Travel/Status/DE/DBWagenreihung/Carriage.pm +26 −0 Original line number Original line Diff line number Diff line Loading @@ -13,9 +13,24 @@ Travel::Status::DE::DBWagenreihung::Carriage->mk_ro_accessors( qw(class_type is_closed is_dosto is_locomotive is_powercar qw(class_type is_closed is_dosto is_locomotive is_powercar number model section uic_id type number model section uic_id type start_meters end_meters length_meters start_percent end_percent length_percent start_meters end_meters length_meters start_percent end_percent length_percent has_priority_seats has_ac has_quiet_zone has_bahn_comfort has_wheelchair_space has_wheelchair_toilet has_family_zone has_infant_cabin has_info has_bistro has_first_class has_second_class ) ) ); ); my %type_map = ( SEATS_SEVERELY_DISABLE => 'priority_seats', AIR_CONDITION => 'ac', ZONE_QUIET => 'quiet_zone', SEATS_BAHN_COMFORT => 'bahn_comfort', INFO => 'info', TOILET_WHEELCHAIR => 'wheelchair_toilet', WHEELCHAIR_SPACE => 'wheelchair_space', ZONE_FAMILY => 'family_zone', CABIN_INFANT => 'infant_cabin', ); sub new { sub new { my ( $obj, %opt ) = @_; my ( $obj, %opt ) = @_; my $ref = {}; my $ref = {}; Loading @@ -40,6 +55,14 @@ sub new { $self->parse_type; $self->parse_type; for my $amenity ( @{ $json{amenities} // [] } ) { my $type = $amenity->{type}; if ( $type_map{$type} ) { my $key = 'has_' . $type_map{$type}; $self->{$key} = 1; } } if ( $json{status} and $json{status} eq 'CLOSED' ) { if ( $json{status} and $json{status} eq 'CLOSED' ) { $ref->{is_closed} = 1; $ref->{is_closed} = 1; } } Loading @@ -54,6 +77,9 @@ sub new { $ref->{is_powercar} = 1; $ref->{is_powercar} = 1; } } $ref->{has_first_class} = $json{type}{hasFirstClass}; $ref->{has_second_class} = $json{type}{hasEconomyClass}; if ( $ref->{type} =~ m{AB} ) { if ( $ref->{type} =~ m{AB} ) { $ref->{class_type} = 12; $ref->{class_type} = 12; } } Loading Loading
lib/Travel/Status/DE/DBWagenreihung/Carriage.pm +26 −0 Original line number Original line Diff line number Diff line Loading @@ -13,9 +13,24 @@ Travel::Status::DE::DBWagenreihung::Carriage->mk_ro_accessors( qw(class_type is_closed is_dosto is_locomotive is_powercar qw(class_type is_closed is_dosto is_locomotive is_powercar number model section uic_id type number model section uic_id type start_meters end_meters length_meters start_percent end_percent length_percent start_meters end_meters length_meters start_percent end_percent length_percent has_priority_seats has_ac has_quiet_zone has_bahn_comfort has_wheelchair_space has_wheelchair_toilet has_family_zone has_infant_cabin has_info has_bistro has_first_class has_second_class ) ) ); ); my %type_map = ( SEATS_SEVERELY_DISABLE => 'priority_seats', AIR_CONDITION => 'ac', ZONE_QUIET => 'quiet_zone', SEATS_BAHN_COMFORT => 'bahn_comfort', INFO => 'info', TOILET_WHEELCHAIR => 'wheelchair_toilet', WHEELCHAIR_SPACE => 'wheelchair_space', ZONE_FAMILY => 'family_zone', CABIN_INFANT => 'infant_cabin', ); sub new { sub new { my ( $obj, %opt ) = @_; my ( $obj, %opt ) = @_; my $ref = {}; my $ref = {}; Loading @@ -40,6 +55,14 @@ sub new { $self->parse_type; $self->parse_type; for my $amenity ( @{ $json{amenities} // [] } ) { my $type = $amenity->{type}; if ( $type_map{$type} ) { my $key = 'has_' . $type_map{$type}; $self->{$key} = 1; } } if ( $json{status} and $json{status} eq 'CLOSED' ) { if ( $json{status} and $json{status} eq 'CLOSED' ) { $ref->{is_closed} = 1; $ref->{is_closed} = 1; } } Loading @@ -54,6 +77,9 @@ sub new { $ref->{is_powercar} = 1; $ref->{is_powercar} = 1; } } $ref->{has_first_class} = $json{type}{hasFirstClass}; $ref->{has_second_class} = $json{type}{hasEconomyClass}; if ( $ref->{type} =~ m{AB} ) { if ( $ref->{type} =~ m{AB} ) { $ref->{class_type} = 12; $ref->{class_type} = 12; } } Loading