summaryrefslogtreecommitdiff
path: root/lib/Travel
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-01-03 21:01:14 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-01-03 21:01:14 +0100
commita292fc5ba4a8be919f2fc467cf528b79a6f8c7a3 (patch)
tree6303f4d15c4bed9a19671604f1b17bec6cc09315 /lib/Travel
parent6436acb5833ecec7f6bddc33461efb8c875d19b5 (diff)
add origin/destination accessors, support wings in orig/dest/train no
Diffstat (limited to 'lib/Travel')
-rw-r--r--lib/Travel/Status/DE/DBWagenreihung.pm61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/Travel/Status/DE/DBWagenreihung.pm b/lib/Travel/Status/DE/DBWagenreihung.pm
index 51253f9..2febe4d 100644
--- a/lib/Travel/Status/DE/DBWagenreihung.pm
+++ b/lib/Travel/Status/DE/DBWagenreihung.pm
@@ -8,6 +8,7 @@ our $VERSION = '0.00';
use Carp qw(cluck confess);
use JSON;
+use List::Util qw(uniq);
use LWP::UserAgent;
use Travel::Status::DE::DBWagenreihung::Section;
use Travel::Status::DE::DBWagenreihung::Wagon;
@@ -92,6 +93,46 @@ sub direction {
return $self->{direction};
}
+sub origins {
+ my ($self) = @_;
+
+ if ( exists $self->{origins} ) {
+ return @{ $self->{origins} };
+ }
+
+ my @origins;
+
+ for my $group ( @{ $self->{data}{istformation}{allFahrzeuggruppe} } ) {
+ push( @origins, $group->{startbetriebsstellename} );
+ }
+
+ @origins = uniq @origins;
+
+ $self->{origins} = \@origins;
+
+ return @origins;
+}
+
+sub destinations {
+ my ($self) = @_;
+
+ if ( exists $self->{destinations} ) {
+ return @{ $self->{destinations} };
+ }
+
+ my @destinations;
+
+ for my $group ( @{ $self->{data}{istformation}{allFahrzeuggruppe} } ) {
+ push( @destinations, $group->{zielbetriebsstellename} );
+ }
+
+ @destinations = uniq @destinations;
+
+ $self->{destinations} = \@destinations;
+
+ return @destinations;
+}
+
sub platform {
my ($self) = @_;
@@ -149,6 +190,26 @@ sub train_type {
return $self->{data}{istformation}{zuggattung};
}
+sub train_numbers {
+ my ($self) = @_;
+
+ if ( exists $self->{train_numbers} ) {
+ return @{ $self->{train_numbers} };
+ }
+
+ my @numbers;
+
+ for my $group ( @{ $self->{data}{istformation}{allFahrzeuggruppe} } ) {
+ push( @numbers, $group->{verkehrlichezugnummer} );
+ }
+
+ @numbers = uniq @numbers;
+
+ $self->{train_numbers} = \@numbers;
+
+ return @numbers;
+}
+
sub train_no {
my ($self) = @_;