summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2017-01-13 19:00:33 +0100
committerDaniel Friesel <derf@finalrewind.org>2017-01-13 19:00:33 +0100
commitc280291a0b7150c902e9dae5f4f670148307bdf3 (patch)
treec1e7ce8e04cf7e43ce9f3b90577b01c16dba240b /lib
parent5874d734a0d851369a45f2ad869be03a8699162d (diff)
initial support for stop messages (todo: documentation) (closes #6)
Diffstat (limited to 'lib')
-rw-r--r--lib/Travel/Status/DE/URA.pm37
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/URA.pm b/lib/Travel/Status/DE/URA.pm
index f290e53..be405c2 100644
--- a/lib/Travel/Status/DE/URA.pm
+++ b/lib/Travel/Status/DE/URA.pm
@@ -63,6 +63,9 @@ sub new {
},
};
+ if ( $opt{with_messages} ) {
+ $self->{post}{ReturnList} .= ',messagetext,messagetype';
+ }
if ( $opt{with_stops} ) {
$self->{post}{StopAlso} = 'True';
}
@@ -158,7 +161,20 @@ sub parse_raw_data {
);
}
}
- if ( $type == TYPE_PREDICTION ) {
+ elsif ( $type == TYPE_MESSAGE ) {
+ push(
+ @{ $self->{messages} },
+ {
+ stop_name => $fields[1],
+ stop_id => $fields[2],
+
+ # 0 = long text. 2 = short text for station displays?
+ type => $fields[6],
+ text => $fields[7],
+ }
+ );
+ }
+ elsif ( $type == TYPE_PREDICTION ) {
push( @{ $self->{stop_names} }, $fields[1] );
}
}
@@ -193,6 +209,25 @@ sub errstr {
return $self->{errstr};
}
+sub messages_by_stop_id {
+ my ( $self, $stop_id ) = @_;
+
+ my @messages = grep { $_->{stop_id} == $stop_id } @{ $self->{messages} };
+ @messages = map { $_->{text} } @messages;
+
+ return @messages;
+}
+
+sub messages_by_stop_name {
+ my ( $self, $stop_name ) = @_;
+
+ my @messages
+ = grep { $_->{stop_name} eq $stop_name } @{ $self->{messages} };
+ @messages = map { $_->{text} } @messages;
+
+ return @messages;
+}
+
sub results {
my ( $self, %opt ) = @_;
my @results;