summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/aseag-m16
-rw-r--r--lib/Travel/Status/DE/ASEAG.pm21
2 files changed, 22 insertions, 15 deletions
diff --git a/bin/aseag-m b/bin/aseag-m
index 1fb593f..5c2c453 100755
--- a/bin/aseag-m
+++ b/bin/aseag-m
@@ -33,15 +33,13 @@ if ( @ARGV != 1 ) {
my ($stop_name) = @ARGV;
-my $status = Travel::Status::DE::ASEAG->new(
- name => $stop_name,
- full_routes => $show_full_route
-);
+my $status = Travel::Status::DE::ASEAG->new;
sub show_help {
my ($code) = @_;
- print "Usage: aseag-m <stop name>\n" . "See also: man aseag-m\n";
+ print "Usage: B<aseag-m> [ B<-l> I<lines> ] [B<-f>] I< <stop name>\n"
+ . "See also: man aseag-m\n";
exit $code;
}
@@ -83,7 +81,13 @@ sub display_result {
sub show_results {
my @output;
- for my $d ( $status->results ) {
+ for my $d (
+ $status->results(
+ stop => $stop_name,
+ full_routes => $show_full_route
+ )
+ )
+ {
my $dtime = $d->time;
diff --git a/lib/Travel/Status/DE/ASEAG.pm b/lib/Travel/Status/DE/ASEAG.pm
index 488959e..3477231 100644
--- a/lib/Travel/Status/DE/ASEAG.pm
+++ b/lib/Travel/Status/DE/ASEAG.pm
@@ -22,7 +22,7 @@ sub new {
my $self = {
full_routes => $opt{full_routes} // 0,
fuzzy => $opt{fuzzy} // 1,
- stop => $opt{name},
+ stop => $opt{stop},
post => {
ReturnList =>
'lineid,linename,directionid,destinationtext,vehicleid,'
@@ -57,7 +57,7 @@ sub new {
return $self;
}
-sub new_from_xml {
+sub new_from_raw {
my ( $class, %opt ) = @_;
my $self = { raw_str => $opt{raw_str}, };
@@ -101,10 +101,9 @@ sub sprintf_time {
}
sub is_my_stop {
- my ( $self, $stop ) = @_;
- my $my_stop = $self->{stop};
+ my ( $self, $stop, $my_stop, $fuzzy ) = @_;
- if ( $self->{fuzzy} ) {
+ if ($fuzzy) {
return ( $stop =~ m{ $my_stop }ix ? 1 : 0 );
}
else {
@@ -113,9 +112,13 @@ sub is_my_stop {
}
sub results {
- my ($self) = @_;
+ my ( $self, %opt ) = @_;
my @results;
+ my $full_routes = $opt{full_routes} // $self->{full_routes} // 0;
+ my $fuzzy = $opt{fuzzy} // $self->{fuzzy} // 1;
+ my $stop = $opt{stop} // $self->{stop};
+
my $dt_now = DateTime->now( time_zone => 'Europe/Berlin' );
for my $dep ( @{ $self->{raw_list} } ) {
@@ -126,7 +129,7 @@ sub results {
) = @{$dep};
my @route;
- if ( $self->{stop} and not $self->is_my_stop($stopname) ) {
+ if ( $stop and not $self->is_my_stop( $stopname, $stop, $fuzzy ) ) {
next;
}
@@ -135,7 +138,7 @@ sub results {
next;
}
- if ( $self->{full_routes} ) {
+ if ($full_routes) {
@route = map { [ $_->[9] / 1000, $_->[1] ] }
grep { $_->[8] == $tripid } @{ $self->{raw_list} };
@@ -199,7 +202,7 @@ Travel::Status::DE::ASEAG - unofficial ASEAG departure monitor
use Travel::Status::DE::ASEAG;
my $status = Travel::Status::DE::ASEAG->new(
- name => 'Aachen Bushof'
+ stop => 'Aachen Bushof'
);
for my $d ($status->results) {