Frizzle: A Ruby wrapper for the TransLoc API
Frizzle is a Ruby wrapper for the TransLoc Public API.
Supports all the TransLoc v1.2 API methods. You can either use the whole API wrapper through Frizzle or use parts of it i.e. Frizzle::Agencies.all if you solely want to work with a particular resource.
For more information on the TransLoc API, visit http://api.transloc.com/doc/.
Installation
Add this line to your application's Gemfile:
gem 'frizzle'
Or install it yourself as:
gem install "frizzle"
Usage
To start using the gem, you can either perform direct calls on Frizzle
Frizzle.agencies.all
or through the corresponding class and class methods
Frizzle::Agencies.all
The TransLoc API does not require an API key.
Geographical Filtering
For methods that allow limiting the results with a geographical area filter, there are two form options: rectangle form and point and radius form.
To limit with rectangle form, pass two arrays ([lat, lng]) for the two geo area arguments. It would look like:
Frizzle.agencies.find_by_geo_area([35.80176,-78.64347], [35.78061,-78.68218])
To limit with point and radius, pass an array ([lat, lng]) to the first argument.
The second argument is optional and can be used to pass a radius in meters of a circle around the point. If this is not filled out, it will default to 100. If you wish to change the default radius, it can be changed through Frizzle.default_geo_radius or set individually by class.
Frizzle.agencies.find_by_geo_area([35.80176,-78.64347])
Frizzle.agencies.find_by_geo_area([35.80176,-78.64347], 70)
Agencies
Agencies can be accessed through Frizzle.agencies or Frizzle::Agencies. This API call can be requested every 10 seconds from the same IP address.
Examples:
Frizzle::Agencies.all
Frizzle.agencies.all
Frizzle.agencies.find_by_id(168)
Frizzle.agencies.find_by_id([168,24])
Frizzle.agencies.find_by_geo_area([35.80176,-78.64347], 75.5)
Frizzle.agencies.find_by_geo_area([35.80176,-78.64347])
Frizzle.agencies.find_by_id_and_geo_area("168", [35.80176,-78.64347])
Frizzle.agencies.find_by_id_and_geo_area("168", [35.80176,-78.64347], 120)
Frizzle.agencies.find({:agencies => "12", :geo_area => "35.80176,-78.64347|100"})
Segments
Segments can be accessed through Frizzle.segments or Frizzle::Segments. This API call can be requested every 10 seconds from the same IP address.
Examples:
Frizzle::Segments.find_by_agencies(24)
Frizzle.segments.find_by_agencies(24)
Frizzle.segments.find_by_agencies(24)
Frizzle.segments.find_by_agencies([24,22])
Frizzle.segments.find_by_agencies_and_routes(24, [4000078, 4000383])
Frizzle.segments.find_by_agencies_and_geo_area(24, [35.98974,-78.90292])
Frizzle.segments.find_by_agencies_and_geo_area(24, [35.98974,-78.90292], 100)
Frizzle.segments.find({:agencies => "24"}
Routes
Routes can be accessed through Frizzle.routes or Frizzle::Routes. This API call can be requested every 10 seconds from the same IP address.
Examples:
Frizzle::Routes.find_by_agencies("24")
Frizzle.routes.find_by_agencies("24")
Frizzle.routes.find_by_agencies([24, 132])
Frizzle.routes.find_by_agencies_and_geo_area(24, [35.98974,-78.90292])
Frizzle::Routes.find({:agencies => "24"})
Stops
Stops can be accessed through Frizzle.stops or Frizzle::Stops. This API call can be requested every 10 seconds from the same IP address.
Examples:
Frizzle::Stops.find_by_agencies(24)
Frizzle.stops.find_by_agencies(24)
Frizzle.stops.find_by_agencies_and_geo_area(24, [35.98974,-78.90292])
Frizzle::Stops.find({:agencies => "24"})
Vehicles
Vehicles can be accessed through Frizzle.vehicles or Frizzle::Vehicles. This API call can be requested every 1 second from the same IP address.
Examples:
Frizzle::Vehicles.find_by_agencies("24")
Frizzle.vehicles.find_by_agencies("24")
Frizzle.vehicles.find_by_agencies_and_routes("24", ["4003034","4003038"])
Frizzle.vehicles.find_by_agencies_and_routes_geo_area(24, ["4003034","4003038"], [35.98974,-78.90292])
Frizzle::Vehicles.find({:agencies => "24"})
Arrival Estimates
Arrival estimates can be accessed through Frizzle.arrival_estimates or Frizzle::ArrivalEstimates. This API call can be requested every 1 second from the same IP address.
Examples:
Frizzle::ArrivalEstimates.find_by_agencies("24")
Frizzle.arrival_estimates.find_by_agencies("24")
Frizzle.arrival_estimates.find_by_agencies_and_routes("24", ["4003034","4003038"])
Frizzle.arrival_estimates.find_by_agencies_and_stops("24", "1029")
Frizzle.arrival_estimates.find_by_agencies_and_routes_and_stops("24", ["4003034","4003038"], "1029")
Frizzle::ArrivalEstimates.find({:agencies => "24"})
Contributing
This is my first Ruby gem, so any issues or pull requests with suggested improvements is appreciated.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
License
Copyright (c) 2013 Tyler Pearson. See LICENSE for details.

