NAME WWW::PTV::Area - a utility class for working with Public Transport Victoria (PTV) areas.
SYNOPSIS
my $ptv = WWW::PTV->new;
my $area = $ptv->get_area_by_id(30);
print "\n\nThe ". $area->name ." area encapsulates the following suburbs and towns:\n - ";
print join "\n - ", @{ $area->suburbs };
print "\n\nServices in this area include:\n";
my @service_types = $area->service_types;
my $service_names = $area->service_names;
my $service_links = $area->service_links;
foreach my $type ( @service_types ) {
print "\n - $type\n";
foreach my $name ( @{ $service_names->{ $type } } ) {
print "\t\t - $name\n"
}
}
METHODS
id ()
Returns the area numerical identifier.
name ()
Returns the area name.
suburbs ()
Returns a list of the suburbs and towns encompassed by this area - the suburb and town names are typically free-form text and are common names for suburbs or towns e.g. Carlton, South Wharf, Echuca, etc.
towns ()
This method is a synonym for the suburbs() method.
service_types ()
Returns a list of the service types operating within this area - the service names are free-form text describing the service e.g. Train Stations, Metropolitan Trams, etc.
service_names ()
Returns a hash containing the service names servicing the area as lists indexed by the service type;
'Metropolitan Trains' => [
'Alamein Line',
'Belgrave Line',
'Craigieburn Line',
...
],
'Metropolitan Trams' => [
'200 - Bulleen',
...
],
...
service_links ()
Returns a hash containing URLs for the routes and stops servicing the area - these lists positionally correspond to the items in the lists returned for service names as returned by the service_names() method.
'Metropolitan Trains' => [
'http://ptv.vic.gov.au/route/view/1', # Alamein Line
'http://ptv.vic.gov.au/route/view/2', # Belgrave Line
'http://ptv.vic.gov.au/route/view/3', # Craigieburn Line
...
],
'Metropolitan Trams' => [
'http://ptv.vic.gov.au/route/view/7520', # Route 200 - Bulleen
...
],
...
So with minimal effort, it is possible to reliably retrieve the route name and route URL by doing something like;
print "<a href=\"@{ $service_links->{'Metropolitan Trains'} }[0]\">"
. "@{ $service_names->{'Metropolitan Trains'} }[0]</a>\n";
services
Returns all services for the area as a list of anonymous hashes having the structure:
{
name => 'Service Name',
type => 'Service Type',
link => 'URI to service link'
}
services_like ( { name => $name, type => $type } )
Returns a list of anonymous hashes having the structure described in the services method above matching the search criteria defined by %args.
The two valid search criteria accepted are name and type, and any services matching these criteria will be returned. If both criteria are provided, then only services matching both criteria are returned.
# Return only services having a description like "University"
my @services = $area->services_like( name => 'university' );
# Return only services having a description like "University"
# and being of a 'bus' service type.
my @services = $area->services_like( name => 'university',
type => 'bus' );
Note that matching is case-insensitive.
SEE ALSO
WWW::PTV, WWW::PTV::Route, WWW::PTV::Stop, WWW::PTV::TimeTable, WWW::PTV::TimeTable::Schedule
AUTHOR
Luke Poskitt, <ltp at cpan.org>
BUGS
Please report any bugs or feature requests to bug-www-ptv-area at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-PTV-Area. 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::Area
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
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.