class BggApi

because this uses method_missing, the fact that we’re including the HTTParty module below into the namespace doesn’t seem to help. Likewise with the base_uri method. There’s probably some trick to getting this to work, but I haven’t yet figured it out and will put it on the list, but later in the process.

Protected Instance Methods

call(method, params = {}) click to toggle source
# File lib/bgg-api.rb, line 19
def call(method, params = {})
  response = HTTParty.get(@@base_uri + '/' + method.to_s, :query => params)
  
  if response.code == 200
    xml_data = response.body
    XmlSimple.xml_in(xml_data)
  else
    raise response.code
  end
end
method_missing(method, *args) click to toggle source
# File lib/bgg-api.rb, line 30
def method_missing(method, *args)
  call(method, *args)
end
respond_to?(method) click to toggle source
# File lib/bgg-api.rb, line 34
def respond_to?(method)
    true
end