summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/DeutscheBahn
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-07-13 14:13:15 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-07-13 14:13:15 +0200
commit91a31f674b366d4e86a6bfae12c0922c396a7df1 (patch)
tree4cffae1a37284d4c9422e5b9ae3ed3d979e7389d /lib/Travel/Status/DE/DeutscheBahn
parentd0f1eccd06746b602fcc468a6d14465c0195004d (diff)
DeutscheBahn/Result: Add delay accessor, remove info_raw
Diffstat (limited to 'lib/Travel/Status/DE/DeutscheBahn')
-rw-r--r--lib/Travel/Status/DE/DeutscheBahn/Result.pm27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/Travel/Status/DE/DeutscheBahn/Result.pm b/lib/Travel/Status/DE/DeutscheBahn/Result.pm
index 5c2e9e1..79cf5d4 100644
--- a/lib/Travel/Status/DE/DeutscheBahn/Result.pm
+++ b/lib/Travel/Status/DE/DeutscheBahn/Result.pm
@@ -38,6 +38,21 @@ sub info {
return $info;
}
+sub delay {
+ my ($self) = @_;
+
+ my $info = $self->info_raw;
+
+ if ( $info =~ m{ p.nktlich }ox ) {
+ return 0;
+ }
+ if ( $info =~ m{ ca[.] \s (?<delay> \d+ ) \s Minuten \s sp.ter }ox ) {
+ return $+{delay};
+ }
+
+ return;
+}
+
sub origin {
my ($self) = @_;
@@ -156,16 +171,14 @@ either the train's destination or its origin station.
Convenience aliases for $result->route_end.
-=item $result->info
+=item $result->delay
-Returns additional information, for instance in case the train is delayed. May
-be an empty string if no (useful) information is available.
+Returns the train's delay in steps of 5 minutes, or undef if it is unknown.
-=item $result->info_raw
+=item $result->info
-Returns the raw info string. B<info> only tells you about delays, platform
-changes and such, B<info_raw> also explicitly states wether a train is on time
-or no information is available.
+Returns additional information, for instance the reason why the train is
+delayed. May be an empty string if no (useful) information is available.
=item $result->platform