Class: BuBus::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bubus/client.rb

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



7
8
# File 'lib/bubus/client.rb', line 7

def initialize()
end

Instance Method Details

#buses(&block) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/bubus/client.rb', line 10

def buses(&block)
  buses = request(BuBus::Bus::URL)["ResultSet"]["Result"]
  buses = buses.map {|bus| Bus.new(bus) }
  
  return buses unless block_given?
  buses.map {|bus| block.call(bus)} 
end

#stops(&block) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/bubus/client.rb', line 18

def stops(&block)
  stops = request(BuBus::Stop::URL)["ResultSet"]["Result"]
  stops = stops.map {|stop| Stop.new(stop)}

  return stops unless block_given?
  stops.map {|stop| block.call(stop)}
end