se warnings;
use 5.020;
use utf8;
use parent 'Class::Accessor';
use Carp qw(cluck confess);
use JSON;
use List::Util qw(uniq);
use LWP::UserAgent;
use Travel::Status::DE::DBWagenreihung::Group;
use
if ( not $opt{train_number} and not $opt{from_json} ) {
confess('train_number option must be set');
}
if ( not $opt{departure} and not $opt{from_json} ) {
confess('departure option must be set'
departure => $opt{departure},
eva => $opt{eva},
from_json => $opt{from_json},
json => JSON->new,
train_type => $opt{train_type},
train_number => $opt{tra
=> 'infant_cabin',
);
sub new {
my ( $obj, %opt ) = @_;
my $ref = {};
my %json = %{ $opt{json} };
my $platform = $opt{platform};
$ref->{class_type} = 0;
$ref->{has_bistro}
$ref->{number} = $json{wagonIdentificationNumber};
$ref->{model} = $json{vehicleID};
$ref->{uic_id} = $json{vehicleID};
$ref->{section} = $json{platformPosition}{sector
= $json{type}{constructionType};
$ref->{model} =~ s{^.....(...)....(?:-.)?$}{$1} or $ref->{model} = undef;
my $self = bless( $ref, $obj );
$self->parse_type;
for my $amenity ( @{ $json{amen
type} =~ m{^D?A?B} ) {
return 1;
}
return 0;
}
sub sections {
my ($self) = @_;
return @{ $self->{sections} };
}
sub TO_JSON {
my ($self) = @_;
my %copy = %{$self};
return {%copy};
}
1;
my %json = %{ $opt{json} };
my $ref = {
carriages => $opt{carriages},
destination => $json{transport}{destination}{name},
train_type => $json{transport}{category},
name => $json{na
me},
line => $json{transport}{numberwline},
train_no => $json{transport}{number},
};
if ( $ref->{name} =~ m{ ^ IC[DE] 0* (\d+) $ }x and exists $ice_name{$1} ) {
$ref->{designation}
$ref->{sectors} = [
uniq grep { defined }
map { $_->{platformPosition}{sector} } @{ $json{vehicles} // [] }
];
if ( @{ $ref->{sectors} } ) {
$ref->{has_sectors} = 1;
}
$ref->{start
_meters cube_meters cube_percent)
);
sub new {
my ( $obj, %opt ) = @_;
my %section = %{ $opt{json} };
my %platform = %{ $opt{platform} };
my $platform_length = $platform{end} - $platform{start
orm_length,
};
$ref->{length_percent} = $ref->{end_percent} - $ref->{start_percent};
return bless( $ref, $obj );
}
sub TO_JSON {
my ($self) = @_;
my %copy = %{$self};
return {%copy};
}
1;
>{start_meters};
$ref->{length_percent} = $ref->{end_percent} - $ref->{start_percent};
return bless( $ref, $obj );
}
sub TO_JSON {
my ($self) = @_;
my %copy = %{$self};
return {%copy};
}
1;