version 0.003
WWW::IRail::API::Liveboard - HTTP::Request builder and HTTP::Response parser for the IRail API Liveboard data
make_request ( station => 'oostende' ); # departures by default make_request ( to => 'oostende' ); # arrivals coming into oostende
This module builds a HTTP::Request and has a parser for the HTTP::Response. It's up to you to transmit it over the wire. If don't want to do that yourself, don't use this module directly and use WWW::IRail::API instead.
Only the station argument is required, but if you either use to or from it will be seen as the station name with the direction set accordingly. Memento: trains leaving from => 'oostende' and trains arriving into => 'oostende'. If the direction could not be deduced it defaults to 'departures'
station
to
from
'departures'
make_request ( from => 'oostende' ); make_request ( station => 'oostende', direction => 'departures' ); make_request ( { station => 'oostende', dir => 'arr' } );
the API direction parameter is extracted from your input using m/(arr|dep)/i so you can choose between less typing or better readability.
m/(arr|dep)/i
rses the HTTP::Response you got back from the server, which if all went well contains XML. That XML is then transformed into other data formats
xml
XML
YAML
JSON
perl (default)
<liveboard station="MOLLEM" timestamp="1291044188"> <departures> <departure platform="1" station="DENDERMONDE" time="1291043100" vehicle="BE.NMBS.CR1564" /> <departure platform="1" station="DENDERMONDE" time="1291044480" vehicle="BE.NMBS.CR5316" /> <departure platform="2" station="GERAARDSBERGEN" time="1291046100" vehicle="BE.NMBS.CR1588" /> <departure platform="1" station="DENDERMONDE" time="1291046700" vehicle="BE.NMBS.CR1565" /> </departures> </liveboard>
<liveboard timestamp="1291044222" version="1.0"> <departures name="departure" number="4"> <departure id="0" delay="1200" vehicle="BE.NMBS.CR1564"> <platform normal="1">1</platform> <station id="BE.NMBS.137" locationX="4.101431" locationY="51.022775">DENDERMONDE</station> <time formatted="2010-11-29T15:05:00Z">1291043100</time> </departure> <departure id="1" delay="1140" vehicle="BE.NMBS.CR5316"> <platform normal="1">1</platform> <station id="BE.NMBS.137" locationX="4.101431" locationY="51.022775">DENDERMONDE</station> <time formatted="2010-11-29T15:28:00Z">1291044480</time> </departure> <departure id="2" delay="0" vehicle="BE.NMBS.CR1588"> <platform normal="1">2</platform> <station id="BE.NMBS.210" locationX="3.871956" locationY="50.771025">GERAARDSBERGEN</station> <time formatted="2010-11-29T15:55:00Z">1291046100</time> </departure> <departure id="3" delay="0" vehicle="BE.NMBS.CR1565"> <platform normal="1">1</platform> <station id="BE.NMBS.137" locationX="4.101431" locationY="51.022775">DENDERMONDE</station> <time formatted="2010-11-29T16:05:00Z">1291046700</time> </departure> </departures> <station id="BE.NMBS.376" locationX="4.21675" locationY="50.932808">MOLLEM</station> </liveboard>
--- departures: - platform: 1 station: DENDERMONDE time: 1291043100 vehicle: BE.NMBS.CR1564 - platform: 1 station: DENDERMONDE time: 1291044480 vehicle: BE.NMBS.CR5316 - platform: 2 station: GERAARDSBERGEN time: 1291046100 vehicle: BE.NMBS.CR1588 - platform: 1 station: DENDERMONDE time: 1291046700 vehicle: BE.NMBS.CR1565 station: MOLLEM timestamp: 1291044267
{ "departures" : [ { "station" : "DENDERMONDE", "time" : "1291043100", "vehicle" : "BE.NMBS.CR1564", "platform" : "1" }, { "station" : "DENDERMONDE", "time" : "1291044480", "vehicle" : "BE.NMBS.CR5316", "platform" : "1" }, { "station" : "GERAARDSBERGEN", "time" : "1291046100", "vehicle" : "BE.NMBS.CR1588", "platform" : "2" }, { "station" : "DENDERMONDE", "time" : "1291046700", "vehicle" : "BE.NMBS.CR1565", "platform" : "1" } ], "station" : "MOLLEM", "timestamp" : "1291044295" }
{ 'departures' => [ { 'station' => 'DENDERMONDE', 'time' => '1291043100', 'vehicle' => 'BE.NMBS.CR1564', 'platform' => '1' }, { 'station' => 'DENDERMONDE', 'time' => '1291044480', 'vehicle' => 'BE.NMBS.CR5316', 'platform' => '1' }, { 'station' => 'GERAARDSBERGEN', 'time' => '1291046100', 'vehicle' => 'BE.NMBS.CR1588', 'platform' => '2' }, { 'station' => 'DENDERMONDE', 'time' => '1291046700', 'vehicle' => 'BE.NMBS.CR1565', 'platform' => '1' } ], 'station' => 'MOLLEM', 'timestamp' => '1291044344' };
See perlmodinstall for information and options on installing Perl modules.
No bugs have been reported.
Please report any bugs or feature requests through the web interface at http://rt.cpan.org.
Tim Esselens <tim.esselens@gmail.com>
This software is copyright (c) 2010 by Tim Esselens.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install WWW::IRail::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::IRail::API
CPAN shell
perl -MCPAN -e shell install WWW::IRail::API
For more information on module installation, please visit the detailed CPAN module installation guide.