Class: Bart::Client::Stops

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

Instance Method Summary collapse

Methods inherited from API

#get_request, include_api, #post_request, #refresh, require_all, singleton

Methods included from Bart::Connection

#adapter, #connection, #register_adapter

Instance Method Details

#get(id) ⇒ Object Also known as: find

Return the route whose id matches the given id



14
15
16
17
# File 'lib/bart_api/client/stops.rb', line 14

def get id
  parsed = get_request '/api/stn.aspx', query: { cmd: :stninfo, orig: id }
  Stop.new parsed['root']['stations']['station']
end

#listObject Also known as: all

Return a list of all stops on the system.



6
7
8
9
# File 'lib/bart_api/client/stops.rb', line 6

def list
  parsed = get_request '/api/stn.aspx', query: { cmd: :stns }
  parsed['root']['stations']['station'].map { |stop| Stop.new stop }
end