NAME

WWW::PTV::TimeTable::Schedule - Class for operations with PTV time table schedules.

SYNOPSIS

use WWW::PTV;
my $ptv = WWW::PTV->new;

# Get the next outbound departure time for route 1 from stop ID 19849
my $next = $ptv->get_route_by_id(1)
	       ->get_outbound_tt
	       ->get_schedule_by_stop_id(19849)
	       ->next;

print "The next service is scheduled at @$next\n";

# Get the next five services for route 1 from the same stop.
my $next = $ptv->get_route_by_id(1)
	       ->get_outbound_tt
	       ->get_schedule_by_stop_id(19849)
	       ->next_five;

DESCRIPTION

This module implements a utility class providing operations for PTV timetable schedules.

Please note the terminology used for the naming of this module should not imply relationships between routes, timetables, schedules and other objects. In brief, the relationships between objects defined in the WWW::PTV namespace are:

       1       *
route --- has ---> timetables

           1       *
timetable --- has ---> schedules

          1       *
schedule --- has ---> stops (service times)

That is to say; a route may have one or more timetables (inbound, outbound, weekend, public holiday, etc.), each of which is composed of one or more schedules where a schedules is defined as the list of service times for a particular stop on that route.

METHODS

next ( $INT )

my $next = $schedule->next;
print "The next service arrives at $$next[0]:$$next[1]\n";
# The next service arrives at 18:10

Returns the next chronological service time on the schedule in respect to the current local time as a list of two values corresponding to the hour and minute respectively.

This method accepts an integer value as an optional parameter which, if passed specifies the number of the next n service times to return.

# Return the next three service times
my @next_three_trains = $timetable->next(3);

next_five ()

Returns the chronological next five service times for the schedule emulating the popular "next five" feature on the PTV website.

The service times are returned as a list of lists of hour, minute values. See next for more information.

index_of_next ()

Returns an integer value which corresponds to the index of the next service in the array returned by the as_list() method.

# e.g. The service that I just missed was
my $previous = ($schedule)->[$schedule->index_of_next - 1];

Note that the invocation in the example above may not return a service time, but could return a sequence of characters indicating special service states.

as_list ()

Returns the complete schedule as an ordered list. Note that schedule times may not conform to a standard format (e.g. hh:mm) and may use ASCII or Unicode characters to indicate special values.

pretty_print ()

Prints the current date and time and a nicely formatted schedule with the next service time clearly highlighted.

SEE ALSO

WWW::PTV, WWW::PTV::Area, WWW::PTV::Route, WWW::PTV::Stop, WWW::PTV::TimeTable.

AUTHOR

Luke Poskitt, <ltp at cpan.org>

BUGS

Please report any bugs or feature requests to bug-www-ptv-timetable-schedule at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-PTV-TimeTable-Schedule. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc WWW::PTV::TimeTable::Schedule

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2014 Luke Poskitt.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.