The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Travel::Status::DE::DeutscheBahn - Interface to the DeutscheBahn online arrival/departure monitor

SYNOPSIS

        use Travel::Status::DE::DeutscheBahn;

        my $status = Travel::Status::DE::DeutscheBahn->new(
                station => 'Essen Hbf',
        );

        if (my $err = $status->errstr) {
                die("Request error: ${err}\n");
        }

        for my $departure ($status->results) {
                printf(
                        "At %s: %s to %s from platform %s\n",
                        $departure->time,
                        $departure->line,
                        $departure->destination,
                        $departure->platform,
                );
        }

VERSION

version 1.03

DESCRIPTION

Travel::Status::DE::DeutscheBahn is an interface to the DeutscheBahn arrival/departure monitor available at http://reiseauskunft.bahn.de/bin/bhftafel.exe/dn.

It takes a station name and (optional) date and time and reports all arrivals or departures at that station starting at the specified point in time (now if unspecified).

METHODS

my $status = Travel::Status::DE::DeutscheBahn->new(%opts)

Requests the departures/arrivals as specified by opts and returns a new Travel::Status::DE::DeutscheBahn element with the results. Dies if the wrong opts were passed.

Supported opts are:

station => station

The train station to report for, e.g. "Essen HBf" or "Alfredusbad, Essen (Ruhr)". Mandatory.

date => dd.mm.yyyy

Date to report for. Defaults to the current day.

language => language

Set language for additional information. Accepted arguments: deutsch, english, italian, n (dutch).

time => hh:mm

Time to report for. Defaults to now.

mode => arr|dep

By default, Travel::Status::DE::DeutscheBahn reports train departures (dep). Set this to arr to get arrivals instead.

mot => \%hashref

Modes of transport to show. Accepted keys are: ice (ICE trains), ic_ec (IC and EC trains), d (InterRegio and similarly fast trains), nv ("Nahverkehr", mostly RegionalExpress trains), s ("S-Bahn"), bus, ferry, u ("U-Bahn") and tram.

Setting a mode (as hash key) to 1 includes it, 0 excludes it. undef leaves it at the default.

By default, the following are shown: ice, ic_ec, d, nv, s.

$status->errstr

In case of an error in the HTTP request, returns a string describing it. If no error occured, returns undef.

$status->results

Returns a list of arrivals/departures. Each list element is a Travel::Status::DE::DeutscheBahn::Result(3pm) object.

If no matching results were found or the parser / http request failed, returns undef.

DIAGNOSTICS

None.

DEPENDENCIES

  • Class::Accessor(3pm)

  • LWP::UserAgent(3pm)

  • XML::LibXML(3pm)

BUGS AND LIMITATIONS

There are a few character encoding issues.

SEE ALSO

Travel::Status::DE::DeutscheBahn::Result(3pm).

AUTHOR

Copyright (C) 2011 by Daniel Friesel <derf@finalrewind.org>

LICENSE

This module is licensed under the same terms as Perl itself.