WebService::OCTranspo - Access Ottawa bus schedule information from www.octranspo.com


WebService-OCTranspo documentation  | view source Contained in the WebService-OCTranspo distribution.

Index


NAME

Top

WebService::OCTranspo - Access Ottawa bus schedule information from www.octranspo.com

SYNOPSIS

Top

    use WebService::OCTranspo;
    my $oc = WebService::OCTranspo->new();

    my $schedule = $oc->schedule_for_stop({
	stop_id  => $stop,
	route_id => $route,
	date     => DateTime->now(),
    });

    print "$s->{route_number} - $s->{route_name} departing $s->{stop_name} ($s->{stop_number})\n";

    foreach my $time ( @{ $s->{times} } ) {
	print " $time\n";
    }

  


DESCRIPTION

Top

This module provides access to some of the bus schedule information available from OCTranspo -- the public transit service in Ottawa, Ontario, Canada.

METHODS

Top

new ( )

Creates a new WebService::OCTranspo object

schedule_for_stop ( $args )

Fetch schedule for a single route at a single stop. Returns reference to hash containing schedule info for that route at that stop.

$args must be a hash reference containing all of:

stop_id

The numeric ID of the bus stop. This should be the "560 Code" displayed at each stop, usually used for retrieving the bus stop information by phone.

route_id

The bus route number. Use integers only -- 'X' routes should omit the X suffix.

date

A DateTime object

Return hashref contains:

stop_number

4-digit OC Transpo stop number

stop_name

Name of stop, or 'unknown' if not found

route_number

1 to 3 digit OC Transpo route number

route_name

Name of route, or 'unknown' if not found

times

Reference to array of scalars representing stop times in local Ottawa time. Time values will be in one of two formats: HH:MM for plain times with no modifier, and HH:MM (X) where X is the identifier of a route note mentioned in the notes section of the returned data.

notes

Reference to hash, containing note_identifier => note.

This method will die if the stop is not found, the route is not found, as well as on any WWW::Mechanize or HTML::Form errors that might be thrown.

DEPENDENCIES

Top

WWW::Mechanize, HTML::Form::ForceValue, HTML::TableExtract, HTTP::Status, DateTime

INCOMPATIBILITIES

Top

There are no known incompatibilities with this module, but they probably do exist.

BUGS AND LIMITATIONS

Top

Current known issues:

Please report any new problems to the author. Patches are welcome.

AUTHOR

Top

Dave O'Neill (dmo@dmo.ca)

LICENCE AND COPYRIGHT

Top


WebService-OCTranspo documentation  | view source Contained in the WebService-OCTranspo distribution.