summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/DeutscheBahn/Result.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-05-09 10:00:40 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-05-09 10:00:40 +0200
commitfd5b343a0b56e0e887ab514b38496212beac7b8d (patch)
tree530a36440fdc57de2d1dd250b49fc75301891859 /lib/Travel/Status/DE/DeutscheBahn/Result.pm
parent036fb77c6f84907aa0ff973cfe11d13c1c42c2de (diff)
parse route_info field
Diffstat (limited to 'lib/Travel/Status/DE/DeutscheBahn/Result.pm')
-rw-r--r--lib/Travel/Status/DE/DeutscheBahn/Result.pm18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/DeutscheBahn/Result.pm b/lib/Travel/Status/DE/DeutscheBahn/Result.pm
index 00bfb96..bf300ed 100644
--- a/lib/Travel/Status/DE/DeutscheBahn/Result.pm
+++ b/lib/Travel/Status/DE/DeutscheBahn/Result.pm
@@ -11,7 +11,7 @@ use parent 'Class::Accessor';
our $VERSION = '1.04';
Travel::Status::DE::DeutscheBahn::Result->mk_ro_accessors(
- qw(date time train route_end route_raw platform info_raw));
+ qw(date time train route_end route_raw platform info_raw routeinfo_raw));
sub new {
my ( $obj, %conf ) = @_;
@@ -75,6 +75,17 @@ sub route {
return @stops;
}
+sub route_info {
+ my ($self) = @_;
+
+ my $route_info = $self->routeinfo_raw;
+
+ $route_info =~ s{ ^ [\s\n]+ }{}x;
+ $route_info =~ s{ [\s\n]+ $ }{}x;
+
+ return $route_info;
+}
+
sub route_interesting {
my ( $self, $max_parts ) = @_;
@@ -264,6 +275,11 @@ B<route_raw>.
Similar to B<route>. however, this function returns a list of array
references of the form C<< [ arrival time, station name ] >>.
+=item $result->route_info
+
+Returns a string containing information related to the train's route, such as
+"landslide between X and Y, expect delays".
+
=item $result->time
Returns the arrival/departure time as string in "hh:mm" format.