Class: Waqi::Service::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/waqi/services/base.rb

Direct Known Subclasses

City, Geolocation, Map, Search

Constant Summary collapse

BASE_URL =
'https://api.waqi.info'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



8
9
10
11
# File 'lib/waqi/services/base.rb', line 8

def initialize(params = {})
  @connection = Faraday.new(url: BASE_URL)
  @params = params
end

Instance Method Details

#get(options = {}) ⇒ Object



13
14
15
# File 'lib/waqi/services/base.rb', line 13

def get(options = {})
  parse(@connection.get(self.path, @params.merge(options)))
end

#pathObject



17
18
19
# File 'lib/waqi/services/base.rb', line 17

def path
  raise "path has not beed defined"
end