From 481d3f9c20b7d4239b3b09499bec2c63e31bae93 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 25 Nov 2018 16:14:01 +0100 Subject: Add train classes --- lib/Travel/Status/DE/DBWagenreihung/Wagon.pm | 38 ++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'lib/Travel') diff --git a/lib/Travel/Status/DE/DBWagenreihung/Wagon.pm b/lib/Travel/Status/DE/DBWagenreihung/Wagon.pm index f3569c3..a29d42a 100644 --- a/lib/Travel/Status/DE/DBWagenreihung/Wagon.pm +++ b/lib/Travel/Status/DE/DBWagenreihung/Wagon.pm @@ -8,22 +8,56 @@ use utf8; use parent 'Class::Accessor'; use Carp qw(cluck); -our $VERSION = '1.21'; +our $VERSION = '0.00'; Travel::Status::DE::DBWagenreihung::Wagon->mk_ro_accessors( - qw(number section) + qw(class_type has_bistro number section) ); sub new { my ( $obj, %opt ) = @_; my $ref = \%opt; + $ref->{class_type} = 0; + $ref->{has_bistro} = 0; $ref->{number} = $ref->{wagenordnungsnummer}; $ref->{section} = $ref->{fahrzeugsektor}; + if ($ref->{kategorie} =~ m{SPEISEWAGEN}) { + $ref->{has_bistro} = 1; + } + + if ($ref->{fahrzeugtyp} =~ m{^AB}) { + $ref->{class_type} = 12; + } + elsif ($ref->{fahrzeugtyp} =~ m{^A}) { + $ref->{class_type} = 1; + } + elsif ($ref->{fahrzeugtyp} =~ m{^B|^WR}) { + $ref->{class_type} = 2; + } + return bless( $ref, $obj ); } +sub is_first_class { + my ($self) = @_; + + if ($self->{fahrzeugtyp} =~ m{^A}) { + return 1; + } + return 0; +} + +sub is_second_class { + my ($self) = @_; + + if ($self->{fahrzeugtyp} =~ m{^A?B}) { + return 1; + } + return 0; +} + sub sections { my ($self) = @_; -- cgit v1.2.3