summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-11-25 16:14:01 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-11-25 16:14:01 +0100
commit481d3f9c20b7d4239b3b09499bec2c63e31bae93 (patch)
tree363ff13b6e05222d6b825b5bc3ff26b92905c763
parentacaf6fec0ea994e2901ebffbdd4bd3f5b46c77d6 (diff)
Add train classes
-rw-r--r--bin/dbwagenreihung10
-rw-r--r--lib/Travel/Status/DE/DBWagenreihung/Wagon.pm38
2 files changed, 44 insertions, 4 deletions
diff --git a/bin/dbwagenreihung b/bin/dbwagenreihung
index 0c5b2fe..1d842fa 100644
--- a/bin/dbwagenreihung
+++ b/bin/dbwagenreihung
@@ -27,10 +27,16 @@ if (@trains != 1) {
my $wr = Travel::Status::DE::DBWagenreihung->new(
departure => $trains[0]->sched_departure,
- developer_mode => 1,
train_number => $train_number,
);
for my $wagon ($wr->wagons) {
- printf("%s %s\n", $wagon->number, $wagon->section);
+ printf("%s %2s", $wagon->section, $wagon->number || 'X');
+ if ($wagon->class_type == 12) {
+ print(" 1/2");
+ }
+ elsif ($wagon->class_type) {
+ printf(" %d", $wagon->class_type);
+ }
+ print("\n");
}
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) = @_;