From 0859929dec9f3e4a05b27166373c0b84beea8aab Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sun, 28 Apr 2024 11:49:27 +0200 Subject: remove train_descriptions accessor --- lib/Travel/Status/DE/DBWagenreihung.pm | 45 ++++++---------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) (limited to 'lib/Travel/Status/DE') diff --git a/lib/Travel/Status/DE/DBWagenreihung.pm b/lib/Travel/Status/DE/DBWagenreihung.pm index 6c33971..fcda3ba 100644 --- a/lib/Travel/Status/DE/DBWagenreihung.pm +++ b/lib/Travel/Status/DE/DBWagenreihung.pm @@ -261,29 +261,6 @@ sub wagongroup_powertype { return $likelihood[0]; } -sub parse_train_descriptions { - my ($self) = @_; - - for my $group ( @{ $self->{wagongroups} } ) { - my ( $short, $desc ) = $self->wagongroup_description( $group->wagons ); - my @sections = uniq map { $_->section } $group->wagons; - - if ( @sections and length( join( q{}, @sections ) ) ) { - $group->set_sections(@sections); - } - $group->set_description( $desc, $short ); - - push( - @{ $self->{train_descriptions} }, - { - sections => [@sections], - short => $short, - text => $desc, - } - ); - } -} - sub parse_wagonorder { my ($self) = @_; @@ -299,7 +276,6 @@ sub parse_wagonorder { $self->{train_no} = $self->{data}{istformation}{zugnummer}; $self->parse_wagons; - $self->parse_train_descriptions; $self->{origins} = $self->parse_wings('startbetriebsstellename'); $self->{destinations} = $self->parse_wings('zielbetriebsstellename'); } @@ -350,6 +326,14 @@ sub parse_wagons { wagons => \@group_wagons, ); push( @wagon_groups, $group_obj ); + + my ( $short, $desc ) = $self->wagongroup_description( $group_obj->wagons ); + my @sections = uniq map { $_->section } $group_obj->wagons; + + if ( @sections and length( join( q{}, @sections ) ) ) { + $group_obj->set_sections(@sections); + } + $group_obj->set_description( $desc, $short ); } if ( @{ $self->{wagons} // [] } > 1 and not $self->has_bad_wagons ) { if ( $self->{wagons}[0]->{position}{start_percent} @@ -428,11 +412,6 @@ sub sections { return @{ $self->{sections} // [] }; } -sub train_descriptions { - my ($self) = @_; - return @{ $self->{train_descriptions} // [] }; -} - sub train_numbers { my ($self) = @_; @@ -742,7 +721,6 @@ sub TO_JSON { # ensure that all objects are available $self->train_numbers; - $self->train_descriptions; $self->sections; my %copy = %{$self}; @@ -875,13 +853,6 @@ Returns a hashref describing the requested station. The hashref contains three entries: B (DS100 / Ril100 identifier), B (EVA ID, related to but not necessarily identical with UIC station ID), and B (station name). -=item $wr->train_descriptions - -Returns a list of hashes describing the rolling stock used for this train based -on model and locomotive (if present). Each hash contains the keys B -(textual representation, see C<< $wr->train_desc >>) and B -(arrayref of corresponding sections). - =item $wr->wagongroup_description Returns two strings describing the rolling stock used for this train based on -- cgit v1.2.3