From d33460918190bef8259b19f5793d4fce0e7fe485 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 23 Jun 2011 16:16:41 +0200 Subject: Documentation --- lib/Travel/Status/DE/DeutscheBahn.pm | 77 ++++++++++++++++++++++++ lib/Travel/Status/DE/DeutscheBahn/Departure.pm | 82 +++++++++++++++++++++++++- 2 files changed, 158 insertions(+), 1 deletion(-) (limited to 'lib/Travel/Status/DE') diff --git a/lib/Travel/Status/DE/DeutscheBahn.pm b/lib/Travel/Status/DE/DeutscheBahn.pm index 499f540..748184c 100644 --- a/lib/Travel/Status/DE/DeutscheBahn.pm +++ b/lib/Travel/Status/DE/DeutscheBahn.pm @@ -53,6 +53,21 @@ sub new { return bless( $ref, $obj ); } +sub new_from_html { + my ( $obj, $html ) = @_; + + my $ref = { html => $html, }; + + $ref->{tree} = XML::LibXML->load_html( + string => $ref->{html}, + recover => 2, + suppress_errors => 1, + suppress_warnings => 1, + ); + + return bless( $ref, $obj ); +} + sub departures { my ($self) = @_; @@ -137,30 +152,92 @@ departure monitor =head1 SYNOPSIS + use Travel::Status::DE::DeutscheBahn; + + my $status = Travel::Status::DE::DeutscheBahn->new( + station => 'Essen Hbf', + ); + + for my $departure ($status->departures) { + printf( + "At %s: %s to %s from platform %s\n", + $departure->time, + $departure->train, + $departure->destination, + $departure->platform, + ); + } + =head1 VERSION version 0.0 =head1 DESCRIPTION +Travel::Status::DE::DeutscheBahn is an interface to the DeutscheBahn +arrival/departure monitor available at +L. + +It takes a station name and (optional) date and time and reports all +departures at that station starting at the specified point in time (now if +unspecified). By default, it will list the next 20 departures. + =head1 METHODS =over +=item my $status = Travel::Status::DE::DeutscheBahn->new(I<%opts>) + +Returns a new Travel::Status::DE::DeutscheBahn element. Supported I are: + +=over + +=item B => I + +The train station to report for, e.g. "Essen HBf". Mandatory. + +=item B => I
.I.I + +Date to report for. Defaults to the current day. + +=item B