summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Travel/Status/DE/HAFAS/Journey.pm11
-rwxr-xr-xt/20-db.t5
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Journey.pm b/lib/Travel/Status/DE/HAFAS/Journey.pm
index fba55cd..796afc5 100644
--- a/lib/Travel/Status/DE/HAFAS/Journey.pm
+++ b/lib/Travel/Status/DE/HAFAS/Journey.pm
@@ -16,7 +16,7 @@ Travel::Status::DE::HAFAS::Journey->mk_ro_accessors(
qw(datetime sched_datetime rt_datetime
is_cancelled is_partially_cancelled
platform sched_platform rt_platform operator
- id name type type_long number line load delay
+ id name type type_long class number line load delay
route_end route_start origin destination direction)
);
@@ -86,6 +86,8 @@ sub new {
}
}
+ my $class = $product->{cls};
+
my @stops;
for my $stop ( @{ $journey->{stopL} // [] } ) {
my $loc = $locL[ $stop->{locX} ];
@@ -169,6 +171,7 @@ sub new {
line => $line_no,
type => $cat,
type_long => $catlong,
+ class => $class,
operator => $operator,
direction => $direction,
is_cancelled => $is_cancelled,
@@ -379,6 +382,12 @@ or "STR" for tram / StraE<szlig>enbahn.
Returns the long type of this journey, e.g. "S-Bahn" or "Regional-Express".
+=item $journey->class
+
+Returns an integer identifying the the mode of transport class.
+Semantics depend on backend, e.g. "1" and "2" for long-distance trains and
+"4" and "8" for region trains.
+
=item $journey->line
Returns the line identifier, or undef if it is unknown.
diff --git a/t/20-db.t b/t/20-db.t
index db19da8..71ceead 100755
--- a/t/20-db.t
+++ b/t/20-db.t
@@ -7,7 +7,7 @@ use utf8;
use File::Slurp qw(read_file);
use JSON;
-use Test::More tests => 46;
+use Test::More tests => 49;
use Travel::Status::DE::HAFAS;
@@ -47,6 +47,7 @@ ok( !$results[0]->is_changed_platform, 'result 0: platform not changed' );
is( $results[0]->name, 'Bus 300', 'result 0: name' );
is( $results[0]->type, 'Bus', 'result 0: type' );
is( $results[0]->type_long, 'Bus', 'result 0: type_long' );
+is( $results[0]->class, 32, 'result 0: class' );
is( $results[0]->line, '300', 'result 0: line' );
is( $results[0]->number, '50833', 'result 0: number' );
@@ -77,6 +78,7 @@ ok( !$results[2]->is_changed_platform, 'result 2: platform not changed' );
is( $results[2]->name, 'U 8', 'result 2: name' );
is( $results[2]->type, 'U', 'result 2: type' );
is( $results[2]->type_long, 'U-Bahn', 'result 2: type_long' );
+is( $results[2]->class, 128, 'result 2: class' );
is( $results[2]->line, '8', 'result 2: line' );
is( $results[2]->number, '20024', 'result 2: number' );
@@ -107,6 +109,7 @@ ok( !$results[3]->is_changed_platform, 'result 3: platform not changed' );
is( $results[3]->name, 'S 3', 'result 3: name' );
is( $results[3]->type, 'S', 'result 3: type' );
is( $results[3]->type_long, 'S-Bahn', 'result 3: type_long' );
+is( $results[0]->class, 32, 'result 3: class' );
is( $results[3]->line, '3', 'result 3: line' );
is( $results[3]->number, '3122', 'result 3: number' );