summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-09-11 13:35:24 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-09-11 13:35:24 +0200
commit4ab8c3cc012f4154c79428243d62f94938d7563a (patch)
tree29d20fea9516424f4a5b386a7157a5d3d7cd17a0
parent43f83fc7df3a563521af01dd1251ddd8e8d21d3a (diff)
Allow departure listing for an address / point of interest
-rwxr-xr-xbin/efa-m11
-rw-r--r--lib/Travel/Status/DE/VRR.pm19
2 files changed, 23 insertions, 7 deletions
diff --git a/bin/efa-m b/bin/efa-m
index 0c10ba6..def9f07 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -9,7 +9,7 @@ use Getopt::Long qw(:config no_ignore_case);
use List::Util qw(max);
use Travel::Status::DE::VRR;
-my ( $date, $time );
+my ( $date, $time, $input_type );
my @output;
binmode( STDOUT, ':encoding(utf-8)' );
@@ -26,13 +26,18 @@ if ( @ARGV != 2 ) {
show_help(1);
}
-my ( $place, $station ) = @ARGV;
+my ( $place, $input ) = @ARGV;
+
+if ( $input =~ s{ ^ (?<type> address|poi|stop) : }{}x ) {
+ $input_type = $+{type};
+}
my $status = Travel::Status::DE::VRR->new(
date => $date,
place => $place,
- name => $station,
+ name => $input,
time => $time,
+ type => $input_type,
);
sub show_help {
diff --git a/lib/Travel/Status/DE/VRR.pm b/lib/Travel/Status/DE/VRR.pm
index 3a7375d..a108425 100644
--- a/lib/Travel/Status/DE/VRR.pm
+++ b/lib/Travel/Status/DE/VRR.pm
@@ -17,6 +17,13 @@ sub new {
my $mech = WWW::Mechanize->new();
my @now = localtime( time() );
+ if ( not( $opt{place} and $opt{name} ) ) {
+ confess('You need to specify a place and a name');
+ }
+ if ( $opt{type} and not( $opt{type} ~~ [qw[stop address poi]] ) ) {
+ confess('type must be stop, address or poi');
+ }
+
my $self = {
post => {
command => q{},
@@ -46,7 +53,7 @@ sub new {
sessionID => '0',
submitButton => 'anfordern',
typeInfo_dm => 'invalid',
- type_dm => 'stop',
+ type_dm => $opt{type} // 'stop',
useProxFootSearch => '0',
useRealtime => '1',
},
@@ -170,10 +177,14 @@ Arguments:
Name of the place/city
-=item B<name> => I<stop name>
+=item B<type> => B<address>|B<poi>|B<stop>
+
+Type of the following I<name>. B<poi> means "point of interest". Defaults to
+B<stop> (stop/station name).
+
+=item B<name> => I<name>
-Name of the stop to list departures for. In future versions, this may also
-support street or poi ("point of interest") names
+address / poi / stop name to list departures for.
=back