class Muni::Base
Private Class Methods
build_url(command, options = {})
click to toggle source
# File lib/muni/base.rb, line 17 def build_url(command, options = {}) url = "http://webservices.nextbus.com/service/publicXMLFeed?command=#{command}&a=sf-muni" options.each { |key,value| url << "&#{key}=#{value}" } url end
fetch(command, options = {})
click to toggle source
# File lib/muni/base.rb, line 9 def fetch(command, options = {}) url = build_url(command, options) xml = Net::HTTP.get(URI.parse(url)) doc = XmlSimple.xml_in(xml) || {} fail NextBusError, doc['Error'].first['content'].gsub(/\n/,'') if doc['Error'] doc end