summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2023-01-25 18:58:21 +0100
committerDaniel Friesel <derf@finalrewind.org>2023-01-25 18:58:21 +0100
commit7aea72f583d2eb9576f2cdfe137864d5583bbc51 (patch)
tree675b71db8cdfb3034b85affe796e7564cc8fc084
parent48c69450d431df7fb3773fa36a27fb3093914f9f (diff)
Journey: return full line in "line"; use line_no for line number
-rw-r--r--lib/Travel/Status/DE/HAFAS/Journey.pm14
-rwxr-xr-xt/20-db.t11
2 files changed, 19 insertions, 6 deletions
diff --git a/lib/Travel/Status/DE/HAFAS/Journey.pm b/lib/Travel/Status/DE/HAFAS/Journey.pm
index 10c80fa..2faaf92 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
station station_uic platform sched_platform rt_platform operator
- id name type type_long class number line load delay
+ id name type type_long class number line line_no load delay
route_end route_start origin destination direction)
);
@@ -168,7 +168,8 @@ sub new {
id => $jid,
name => $name,
number => $train_no,
- line => $line_no,
+ line => $name,
+ line_no => $line_no,
type => $cat,
type_long => $catlong,
class => $class,
@@ -451,9 +452,18 @@ Semantics depend on backend, e.g. "1" and "2" for long-distance trains and
=item $journey->line
+Returns the journey or line name, either in a format like "Bus SB16" (Bus line
+SB16), "RE 42" (RegionalExpress train 42) or "IC 2901" (InterCity train 2901,
+no line information). May contain extraneous whitespace characters. Note that
+this accessor does not return line informatikn for IC/ICE/EC services, even if
+it is available. Use B<line_no> for those.
+
+=item $journey->line_no
+
Returns the line identifier, or undef if it is unknown.
The line identifier may be a single number such as "11" (underground train
line U 11), a single word (e.g. "AIR") or a combination (e.g. "SB16").
+May also provide line numbers of IC/ICE services.
=item $journey->number
diff --git a/t/20-db.t b/t/20-db.t
index 71ceead..43bd32d 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 => 49;
+use Test::More tests => 52;
use Travel::Status::DE::HAFAS;
@@ -48,7 +48,8 @@ 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]->line, 'Bus 300', 'result 0: line' );
+is( $results[0]->line_no, '300', 'result 0: line' );
is( $results[0]->number, '50833', 'result 0: number' );
is( $results[0]->operator, 'Nahreisezug', 'result 0: operator' );
@@ -79,7 +80,8 @@ 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]->line, 'U 8', 'result 2: line' );
+is( $results[2]->line_no, '8', 'result 2: line' );
is( $results[2]->number, '20024', 'result 2: number' );
is( $results[2]->operator, 'Nahreisezug', 'result 2: operator' );
@@ -110,7 +112,8 @@ 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]->line, 'S 3', 'result 3: line' );
+is( $results[3]->line_no, '3', 'result 3: line' );
is( $results[3]->number, '3122', 'result 3: number' );
is( $results[3]->operator, 'S-Bahn Berlin', 'result 3: operator' );