NAME
WWW::Oxontime - live Oxford bus departures from Oxontime
SYNOPSIS
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};
}
my
@from_city_centre_to_headington_campus
=
nextbus_from_to NEXTBUS_FROM_CITY_CENTRE,
'Headington Campus'
;
for
my
$line
(
@from_city_centre_to_headington_campus
) {
my
(
$from
,
$service
,
$departs_in
,
$departs_in_mins
) =
@$line
;
say
"Bus $service leaves from $from in $departs_in"
;
}
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. - nextbus_from_to($from, $to)
-
Given a place to start from and a place to arrive at this method returns a list of the next buses to serve that route. $from must be one of the 8 provided constants:
NEXTBUS_FROM_HEADINGTON_CAMPUS
NEXTBUS_FROM_HARCOURT_HILL
NEXTBUS_FROM_MARSTON_ROAD
NEXTBUS_FROM_WHEATLEY_CAMPUS
NEXTBUS_FROM_CRESCENT_HALL
NEXTBUS_FROM_PAUL_KENT_HALL
NEXTBUS_FROM_SLADE_PARK
NEXTBUS_FROM_CITY_CENTRE
whereas $to is the name of an important station.
This function calls the Nextbus service at http://nextbus.brookes.ac.uk/. It is unclear what values for $to are implemented by Nextbus; it is probably best to inspect the website to see what destinations are available.
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.