Class: Nextbus::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Singleton
Defined in:
lib/nextbus/client.rb

Instance Method Summary collapse

Instance Method Details

#agenciesObject



15
16
17
18
# File 'lib/nextbus/client.rb', line 15

def agencies
  response = self.class.do_request("agencyList", {})
  response.agency
end

#directions(agency_id, route_id) ⇒ Object



40
41
42
43
# File 'lib/nextbus/client.rb', line 40

def directions(agency_id, route_id)
  response = self.class.do_request("routeConfig", {"a" => agency_id, "r" => route_id})
  response.route.direction
end

#predictions(agency_id, route_id, stop_id) ⇒ Object



30
31
32
33
# File 'lib/nextbus/client.rb', line 30

def predictions(agency_id, route_id, stop_id)
  response = self.class.do_request("predictions", {"a" => agency_id, "r" => route_id, "s" => stop_id})
  response.predictions.direction.prediction
end

#route(agency_id, route_id) ⇒ Object



25
26
27
28
# File 'lib/nextbus/client.rb', line 25

def route(agency_id, route_id)
  response = self.class.do_request("routeConfig", {"a" => agency_id, "r" => route_id})
  response.route
end

#routes(agency_id) ⇒ Object



20
21
22
23
# File 'lib/nextbus/client.rb', line 20

def routes(agency_id)
  response = self.class.do_request("routeList", {"a" => agency_id})
  response.route
end

#stops(agency_id, route_id, direction_id) ⇒ Object



45
46
47
48
# File 'lib/nextbus/client.rb', line 45

def stops(agency_id, route_id, direction_id)
  response = self.class.do_request("routeConfig", {"a" => agency_id, "r" => route_id})
  response.route.direction.detect{|direction| direction.tag == direction_id }.stop
end

#vehicles(agency_id, route_id, time = Time.now) ⇒ Object



35
36
37
38
# File 'lib/nextbus/client.rb', line 35

def vehicles(agency_id, route_id, time=Time.now)
  response = self.class.do_request("vehicleLocations", {"a" => agency_id, "r" => route_id, "t" => time.to_i.to_s})
  response.vehicle
end