summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/HAFAS.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-09-10 10:23:50 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-09-10 10:23:50 +0200
commit0ebd8e6bb379dba71239050ee643ff78058a95e5 (patch)
treeedca011c1265bfd6bd437bfc38af5d4840706953 /lib/Travel/Status/DE/HAFAS.pm
parent556f259834d75cad6a2feeb1c5106204d5921a28 (diff)
add service list
Diffstat (limited to 'lib/Travel/Status/DE/HAFAS.pm')
-rw-r--r--lib/Travel/Status/DE/HAFAS.pm33
1 files changed, 23 insertions, 10 deletions
diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm
index d091f52..fe8cf2e 100644
--- a/lib/Travel/Status/DE/HAFAS.pm
+++ b/lib/Travel/Status/DE/HAFAS.pm
@@ -14,6 +14,14 @@ use XML::LibXML;
our $VERSION = '1.05';
+my %hafas_instance = (
+ DB => {
+ url => 'http://reiseauskunft.bahn.de/bin/bhftafel.exe',
+ name => 'Deutsche Bahn',
+ productbits => [qw[ice ic_ec d nv s bus ferry u tram ondemand x x x x]],
+ }
+);
+
sub new {
my ( $obj, %conf ) = @_;
@@ -46,21 +54,13 @@ sub new {
boardType => $mode,
L => 'vs_java3',
},
- service => {
- DB => {
- url => 'http://reiseauskunft.bahn.de/bin/bhftafel.exe',
- name => 'Deutsche Bahn',
- productbits =>
- [qw[ice ic_ec d nv s bus ferry u tram ondemand x x x x]],
- }
- },
};
bless( $ref, $obj );
$ref->set_productfilter;
- my $url = $ref->{service}{$service}{url} . '/' . $lang . 'n';
+ my $url = $hafas_instance{$service}{url} . '/' . $lang . 'n';
$reply = $ua->post( $url, $ref->{post} );
@@ -101,7 +101,7 @@ sub set_productfilter {
my $service = $self->{active_service};
$self->{post}{productsFilter}
- = '1' x ( scalar @{ $self->{service}{$service}{productbits} } );
+ = '1' x ( scalar @{ $hafas_instance{$service}{productbits} } );
}
sub check_input_error {
@@ -195,6 +195,19 @@ sub results {
# static
sub get_services {
+ my @services;
+ for my $service ( sort keys %hafas_instance ) {
+ my %desc = %{ $hafas_instance{$service} };
+ $desc{shortname} = $service;
+ push( @services, \%desc );
+ }
+ return @services;
+}
+
+sub get_service {
+ my ($self) = @_;
+
+ return %{ $hafas_instance{ $self->active_service } };
}
1;