NAME
WWW::Oxontime - live Oxford bus departures from Oxontime
SYNOPSIS
use WWW::Oxontime qw/stops_for_route departures_for_stop/;
my @stops_on_8_outbound = stops_for_route 15957;
my $queens_lane = $stops_on_8_outbound[2]->{stopId};
my @from_queens_lane = departures_for_stop $queens_lane;
for my $entry (@from_queens_lane) {
say $entry->{service}, ' towards ', $entry->{destination}, ' departs at ', $entry->{departs};
}
DESCRIPTION
This module wraps http://www.oxontime.com to provide live bus departures in Oxford.
Two methods can be exported (none by default):
- stops_for_route($route_id)
-
Given a route ID (these can be obtained by inspecting the homepage of Oxontime), returns in list context a list of hashrefs having the keys
stopName
(name of stop) andstopId
(ID of stop, suitable for passing todepartures_for_stop
). In scalar context, an arrayref containing this list is returned. - departures_for_stop($stop_id)
-
Given a stop ID (these can be obtained by inspecting the homepage of Oxontime or by calling
stops_for_route
), returns in list context a list of hashrefs having the keysservice
(name of service and company that runs it),destination
(where the service is finishing) anddeparts
(Time::Piece object representing the time when the service departs). In scalar context, an arrayref containing the list is returned.Note that
departs
is in the time zone of Oxford, but Time::Piece interprets it as being in local time. If local time is different from time in Oxford, this needs to be taken into account.
AUTHOR
Marius Gavrilescu, <marius@ieval.ro>
COPYRIGHT AND LICENSE
Copyright (C) 2017 by Marius Gavrilescu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.26.1 or, at your option, any later version of Perl 5 you may have available.