module ChinaAqi::Utility

Public Instance Methods

get() click to toggle source
# File lib/china_aqi/utility.rb, line 18
def get
  ::ActiveSupport::JSON.decode(HTTParty.get(url).body)
end
uri() click to toggle source
# File lib/china_aqi/utility.rb, line 22
def uri
  raise NotImplementedError, "Please set value for 'method' class attributes in '#{self.class.name}' class." unless self.class.method
  method = self.class.method.to_s.include?('/') ? self.class.method : "/querys/#{self.class.method}"
  self.class.base_uri.path = "/api#{method}.json"
  self.class.base_uri.query = @parmas.to_query
  self.class.base_uri
end
url() click to toggle source
# File lib/china_aqi/utility.rb, line 30
def url
  uri.to_s
end