From 75a92d7144bd8700d25d3d420072d8b9f4418d4d Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Fri, 26 Apr 2024 22:00:56 +0200 Subject: Use ClasS::Accessor for platform, train_no, train_type --- lib/Travel/Status/DE/DBWagenreihung.pm | 43 ++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'lib/Travel/Status/DE') diff --git a/lib/Travel/Status/DE/DBWagenreihung.pm b/lib/Travel/Status/DE/DBWagenreihung.pm index 8096452..aa3cd8f 100644 --- a/lib/Travel/Status/DE/DBWagenreihung.pm +++ b/lib/Travel/Status/DE/DBWagenreihung.pm @@ -5,7 +5,7 @@ use warnings; use 5.020; use utf8; -our $VERSION = '0.12'; +use parent 'Class::Accessor'; use Carp qw(cluck confess); use JSON; @@ -14,6 +14,11 @@ use LWP::UserAgent; use Travel::Status::DE::DBWagenreihung::Section; use Travel::Status::DE::DBWagenreihung::Wagon; +our $VERSION = '0.12'; + +Travel::Status::DE::DBWagenreihung->mk_ro_accessors( + qw(platform station train_no train_type)); + my %is_redesign = ( "02" => 1, "03" => 1, @@ -175,6 +180,23 @@ sub get_wagonorder { $self->{data} = $json->{data}; $self->{meta} = $json->{meta}; + + return $self->parse_wagonorder; +} + +sub parse_wagonorder { + my ($self) = @_; + + $self->{platform} = $self->{data}{istformation}{halt}{gleisbezeichnung}; + + $self->{station} = { + ds100 => $self->{data}{istformation}{halt}{rl100}, + eva => $self->{data}{istformation}{halt}{evanummer}, + name => $self->{data}{istformation}{halt}{bahnhofsname}, + }; + + $self->{train_type} = $self->{data}{istformation}{zuggattung}; + $self->{train_no} = $self->{data}{istformation}{zugnummer}; } sub errstr { @@ -194,7 +216,6 @@ sub TO_JSON { $self->train_descriptions; $self->sections; $self->wagons; - $self->{platform} = $self->platform; my %copy = %{$self}; @@ -286,12 +307,6 @@ sub destinations { return @destinations; } -sub platform { - my ($self) = @_; - - return $self->{data}{istformation}{halt}{gleisbezeichnung}; -} - sub sections { my ($self) = @_; @@ -337,12 +352,6 @@ sub station_uic { return $self->{data}{istformation}{halt}{evanummer}; } -sub train_type { - my ($self) = @_; - - return $self->{data}{istformation}{zuggattung}; -} - sub train_numbers { my ($self) = @_; @@ -363,12 +372,6 @@ sub train_numbers { return @numbers; } -sub train_no { - my ($self) = @_; - - return $self->{data}{istformation}{zugnummer}; -} - sub wagongroup_powertype { my ( $self, @wagons ) = @_; -- cgit v1.2.3