Loading bin/dbwagenreihung +35 −31 Original line number Diff line number Diff line Loading @@ -12,7 +12,10 @@ use Travel::Status::DE::DBWagenreihung; my ( $station, $train_number ) = @ARGV; my $res = Travel::Status::DE::IRIS->new(station => $station, with_related => 1); my $res = Travel::Status::DE::IRIS->new( station => $station, with_related => 1 ); if ( $res->errstr ) { say STDERR $res->errstr; Loading Loading @@ -44,8 +47,7 @@ for my $section ($wr->sections) { printf( "|%s%s%s|", ' ' x $spacing_left, $section->name, ' ' x $spacing_right ); ' ' x $spacing_right ); } print "\n"; Loading @@ -54,7 +56,8 @@ print ' ' x ((min @start_percentages) - 1); print '['; for my $wagon ( $wr->wagons ) { my $wagon_length = $wagon->{position}->{end_percent} - $wagon->{position}->{start_percent}; my $wagon_length = $wagon->{position}->{end_percent} - $wagon->{position}->{start_percent}; my $spacing_left = int( $wagon_length / 2 ) - 2; my $spacing_right = int( $wagon_length / 2 ) - 1; Loading @@ -74,7 +77,8 @@ print "]\n"; print ' ' x ( min @start_percentages ); for my $wagon ( $wr->wagons ) { my $wagon_length = $wagon->{position}->{end_percent} - $wagon->{position}->{start_percent}; my $wagon_length = $wagon->{position}->{end_percent} - $wagon->{position}->{start_percent}; my $spacing_left = int( $wagon_length / 2 ) - 2; my $spacing_right = int( $wagon_length / 2 ) - 1; Loading lib/Travel/Status/DE/DBWagenreihung.pm +40 −30 Original line number Diff line number Diff line Loading @@ -61,7 +61,9 @@ sub get_wagonorder { $datetime = $datetime->strftime('%Y%m%d%H%M'); } my ($content, $err) = $self->get_with_cache($cache, "${api_base}/${train_number}/${datetime}"); my ( $content, $err ) = $self->get_with_cache( $cache, "${api_base}/${train_number}/${datetime}" ); if ($err) { $self->{errstr} = "Failed to fetch station data: $err"; Loading Loading @@ -93,13 +95,16 @@ sub sections { for my $section ( @{ $self->{data}{istformation}{halt}{allSektor} } ) { my $pos = $section->{positionamgleis}; push(@{$self->{sections}}, Travel::Status::DE::DBWagenreihung::Section->new( push( @{ $self->{sections} }, Travel::Status::DE::DBWagenreihung::Section->new( name => $section->{sektorbezeichnung}, start_percent => $pos->{startprozent}, end_percent => $pos->{endeprozent}, start_meters => $pos->{startmeter}, end_meters => $pos->{endemeter}, )); ) ); } return @{ $self->{sections} // [] }; Loading @@ -114,10 +119,15 @@ sub wagons { for my $group ( @{ $self->{data}{istformation}{allFahrzeuggruppe} } ) { for my $wagon ( @{ $group->{allFahrzeug} } ) { push(@{$self->{wagons}}, Travel::Status::DE::DBWagenreihung::Wagon->new(%{$wagon})); push( @{ $self->{wagons} }, Travel::Status::DE::DBWagenreihung::Wagon->new( %{$wagon} ) ); } } @{$self->{wagons}} = sort { $a->{position}->{start_percent} <=> $b->{position}->{start_percent} } @{$self->{wagons}}; @{ $self->{wagons} } = sort { $a->{position}->{start_percent} <=> $b->{position}->{start_percent} } @{ $self->{wagons} }; return @{ $self->{wagons} // [] }; } Loading lib/Travel/Status/DE/DBWagenreihung/Wagon.pm +19 −20 Original line number Diff line number Diff line Loading @@ -11,8 +11,7 @@ use Carp qw(cluck); our $VERSION = '0.00'; Travel::Status::DE::DBWagenreihung::Wagon->mk_ro_accessors( qw(class_type has_bistro is_locomotive is_powercar number section) ); qw(class_type has_bistro is_locomotive is_powercar number section)); sub new { my ( $obj, %opt ) = @_; Loading lib/Travel/Status/DE/DBWagenreihung/Section.pm +1 −1 File changed.Contains only whitespace changes. Show changes Loading
bin/dbwagenreihung +35 −31 Original line number Diff line number Diff line Loading @@ -12,7 +12,10 @@ use Travel::Status::DE::DBWagenreihung; my ( $station, $train_number ) = @ARGV; my $res = Travel::Status::DE::IRIS->new(station => $station, with_related => 1); my $res = Travel::Status::DE::IRIS->new( station => $station, with_related => 1 ); if ( $res->errstr ) { say STDERR $res->errstr; Loading Loading @@ -44,8 +47,7 @@ for my $section ($wr->sections) { printf( "|%s%s%s|", ' ' x $spacing_left, $section->name, ' ' x $spacing_right ); ' ' x $spacing_right ); } print "\n"; Loading @@ -54,7 +56,8 @@ print ' ' x ((min @start_percentages) - 1); print '['; for my $wagon ( $wr->wagons ) { my $wagon_length = $wagon->{position}->{end_percent} - $wagon->{position}->{start_percent}; my $wagon_length = $wagon->{position}->{end_percent} - $wagon->{position}->{start_percent}; my $spacing_left = int( $wagon_length / 2 ) - 2; my $spacing_right = int( $wagon_length / 2 ) - 1; Loading @@ -74,7 +77,8 @@ print "]\n"; print ' ' x ( min @start_percentages ); for my $wagon ( $wr->wagons ) { my $wagon_length = $wagon->{position}->{end_percent} - $wagon->{position}->{start_percent}; my $wagon_length = $wagon->{position}->{end_percent} - $wagon->{position}->{start_percent}; my $spacing_left = int( $wagon_length / 2 ) - 2; my $spacing_right = int( $wagon_length / 2 ) - 1; Loading
lib/Travel/Status/DE/DBWagenreihung.pm +40 −30 Original line number Diff line number Diff line Loading @@ -61,7 +61,9 @@ sub get_wagonorder { $datetime = $datetime->strftime('%Y%m%d%H%M'); } my ($content, $err) = $self->get_with_cache($cache, "${api_base}/${train_number}/${datetime}"); my ( $content, $err ) = $self->get_with_cache( $cache, "${api_base}/${train_number}/${datetime}" ); if ($err) { $self->{errstr} = "Failed to fetch station data: $err"; Loading Loading @@ -93,13 +95,16 @@ sub sections { for my $section ( @{ $self->{data}{istformation}{halt}{allSektor} } ) { my $pos = $section->{positionamgleis}; push(@{$self->{sections}}, Travel::Status::DE::DBWagenreihung::Section->new( push( @{ $self->{sections} }, Travel::Status::DE::DBWagenreihung::Section->new( name => $section->{sektorbezeichnung}, start_percent => $pos->{startprozent}, end_percent => $pos->{endeprozent}, start_meters => $pos->{startmeter}, end_meters => $pos->{endemeter}, )); ) ); } return @{ $self->{sections} // [] }; Loading @@ -114,10 +119,15 @@ sub wagons { for my $group ( @{ $self->{data}{istformation}{allFahrzeuggruppe} } ) { for my $wagon ( @{ $group->{allFahrzeug} } ) { push(@{$self->{wagons}}, Travel::Status::DE::DBWagenreihung::Wagon->new(%{$wagon})); push( @{ $self->{wagons} }, Travel::Status::DE::DBWagenreihung::Wagon->new( %{$wagon} ) ); } } @{$self->{wagons}} = sort { $a->{position}->{start_percent} <=> $b->{position}->{start_percent} } @{$self->{wagons}}; @{ $self->{wagons} } = sort { $a->{position}->{start_percent} <=> $b->{position}->{start_percent} } @{ $self->{wagons} }; return @{ $self->{wagons} // [] }; } Loading
lib/Travel/Status/DE/DBWagenreihung/Wagon.pm +19 −20 Original line number Diff line number Diff line Loading @@ -11,8 +11,7 @@ use Carp qw(cluck); our $VERSION = '0.00'; Travel::Status::DE::DBWagenreihung::Wagon->mk_ro_accessors( qw(class_type has_bistro is_locomotive is_powercar number section) ); qw(class_type has_bistro is_locomotive is_powercar number section)); sub new { my ( $obj, %opt ) = @_; Loading
lib/Travel/Status/DE/DBWagenreihung/Section.pm +1 −1 File changed.Contains only whitespace changes. Show changes