Class: DoubleMap::Client::Vehicles

Inherits:
API
  • Object
show all
Extended by:
Memoist
Defined in:
lib/doublemap_api/client/vehicles.rb

Instance Method Summary collapse

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

#listObject 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