Module: ChinaAqi::Utility
Instance Method Summary collapse
Instance Method Details
#get ⇒ Object
18 19 20 |
# File 'lib/china_aqi/utility.rb', line 18 def get ::ActiveSupport::JSON.decode(HTTParty.get(url).body) end |
#uri ⇒ Object
22 23 24 25 26 27 28 |
# 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 ⇒ Object
30 31 32 |
# File 'lib/china_aqi/utility.rb', line 30 def url uri.to_s end |