Class: DoubleMap::Client::Vehicles
- Extended by:
- Memoist
- Defined in:
- lib/doublemap_api/client/vehicles.rb
Instance Method Summary collapse
-
#get(id) ⇒ Object
(also: #find)
Return the vehicle whose id matches the given id.
-
#list ⇒ Object
(also: #all)
Return a list of all vehicles currently traveling on routes.
Methods inherited from API
#get_request, include_api, #post_request, #refresh, require_all, singleton
Methods included from DoubleMap::Connection
#adapter, #connection, #register_adapter
Instance Method Details
#get(id) ⇒ Object Also known as: find
Return the vehicle whose id matches the given id
13 14 15 |
# File 'lib/doublemap_api/client/vehicles.rb', line 13 def get id list.find{ |vehicle| vehicle.id == id } end |
#list ⇒ Object Also known as: all
Return a list of all vehicles currently traveling on routes.
6 7 8 |
# File 'lib/doublemap_api/client/vehicles.rb', line 6 def list get_request('/map/v2/buses').map{ |vehicle| Vehicle.new(vehicle) }.each(&on_vehicle) end |