diff options
author | Daniel Friesel <derf@finalrewind.org> | 2014-12-30 10:48:06 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2014-12-30 10:48:06 +0100 |
commit | 43e06258708282b60b6198166db2185689a408c1 (patch) | |
tree | ebcd458009de5291a1117eaedaaeeef3e81a3806 /lib/Travel/Status/DE | |
parent | 68cd2f9ba17612427b38f6be37039339432100eb (diff) |
Result: Add ->type accessor
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r-- | lib/Travel/Status/DE/DeutscheBahn/Result.pm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Travel/Status/DE/DeutscheBahn/Result.pm b/lib/Travel/Status/DE/DeutscheBahn/Result.pm index fb0fb95..1f9f81c 100644 --- a/lib/Travel/Status/DE/DeutscheBahn/Result.pm +++ b/lib/Travel/Status/DE/DeutscheBahn/Result.pm @@ -137,6 +137,15 @@ sub TO_JSON { return { %{$self} }; } +sub type { + my ($self) = @_; + + # $self->{train} is either "TYPE 12345" or "TYPE12345" + my ($type) = ( $self->{train} =~ m{ ^ ([A-Z]+) }x ); + + return $type; +} + 1; __END__ @@ -259,6 +268,11 @@ references of the form C<< [ arrival time, station name ] >>. Returns the arrival/departure time as string in "hh:mm" format. +=item $result->type + +Returns the type of this train, e.g. "S" for S-Bahn, "RE" for Regional Express +or "ICE" for InterCity-Express. + =back =head2 INTERNAL |