summaryrefslogtreecommitdiff
path: root/lib/Travel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travel')
-rw-r--r--lib/Travel/Status/DE/DeutscheBahn.pm9
-rw-r--r--lib/Travel/Status/DE/DeutscheBahn/Result.pm14
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/Travel/Status/DE/DeutscheBahn.pm b/lib/Travel/Status/DE/DeutscheBahn.pm
index 9cda933..46b679e 100644
--- a/lib/Travel/Status/DE/DeutscheBahn.pm
+++ b/lib/Travel/Status/DE/DeutscheBahn.pm
@@ -117,8 +117,8 @@ sub results {
my $xp_info = XML::LibXML::XPathExpression->new('./td[@class="ris"]');
my $re_via = qr{
- ^ \s* (.+?) \s* \n
- \d{1,2}:\d{1,2}
+ ^ \s* (?<stop> .+? ) \s* \n
+ (?<time> \d{1,2}:\d{1,2} )
}mx;
if ( defined $self->{results} ) {
@@ -164,13 +164,12 @@ sub results {
$first = 0;
next;
}
- my $stop = $1;
- if ( $stop =~ m{ [(] Halt \s entf.llt [)] }ox ) {
+ if ( $+{stop} =~ m{ [(] Halt \s entf.llt [)] }ox ) {
next;
}
- push( @via, $stop );
+ push( @via, [ $+{time}, $+{stop} ] );
}
push(
diff --git a/lib/Travel/Status/DE/DeutscheBahn/Result.pm b/lib/Travel/Status/DE/DeutscheBahn/Result.pm
index 1ed2527..1d05fe9 100644
--- a/lib/Travel/Status/DE/DeutscheBahn/Result.pm
+++ b/lib/Travel/Status/DE/DeutscheBahn/Result.pm
@@ -62,7 +62,8 @@ sub origin {
sub route {
my ($self) = @_;
- return @{ $self->{route} };
+ my @stops = map { $_->[1] } @{ $self->{route} };
+ return @stops;
}
sub route_interesting {
@@ -115,6 +116,12 @@ sub route_interesting {
}
+sub route_timetable {
+ my ($self) = @_;
+
+ return @{ $self->{route} };
+}
+
1;
__END__
@@ -217,6 +224,11 @@ Returns the raw string used to create the route array.
Note that canceled stops are filtered from B<route>, but still present in
B<route_raw>.
+=item $result->route_timetable
+
+Similar to B<route>. however, this function returns a list of array
+references of the form C<< [ arrival time, station name ] >>.
+
=item $result->time
Returns the arrival/departure time as string in "hh:mm" format.