Class: TtcUrls

Inherits:
Object
  • Object
show all
Defined in:
lib/ttc_feed/ttc_urls.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agency_tag = "ttc") ⇒ TtcUrls

Returns a new instance of TtcUrls.



7
8
9
10
# File 'lib/ttc_feed/ttc_urls.rb', line 7

def initialize(agency_tag = "ttc")
  @agency_tag = agency_tag
  @base = Zurl.new("http://webservices.nextbus.com/service/publicXMLFeed")
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



5
6
7
# File 'lib/ttc_feed/ttc_urls.rb', line 5

def base
  @base
end

Instance Method Details

#predictions(stop_id, route_tag) ⇒ Object

stop_id = “14935” route_tag = “512”



23
24
25
# File 'lib/ttc_feed/ttc_urls.rb', line 23

def predictions(stop_id, route_tag)
  @base.stopId(stop_id).r(route_tag).a(@agency_tag).to_s
end

#route_config(route_tag) ⇒ Object

route_tag = “512”



17
18
19
# File 'lib/ttc_feed/ttc_urls.rb', line 17

def route_config(route_tag)
  @base.command("routeConfig").a(@agency_tag).r(route_tag).to_s
end

#route_listObject



12
13
14
# File 'lib/ttc_feed/ttc_urls.rb', line 12

def route_list
  @base.command("routeList").a(@agency_tag).to_s
end

#vehicle_locations(route_tag, last_timestamp = nil) ⇒ Object

route_tag = “512”



28
29
30
31
32
# File 'lib/ttc_feed/ttc_urls.rb', line 28

def vehicle_locations(route_tag, last_timestamp = nil)
  url = @base.command("vehicleLocations").a(@agency_tag).r(route_tag)
  url = url.t(last_timestamp) if last_timestamp
  url.to_s
end