Class: Waqi::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(token:) ⇒ Client

Returns a new instance of Client.



6
7
8
# File 'lib/waqi/client.rb', line 6

def initialize(token:)
  @token = token
end

Instance Method Details

#city_feed(city_name) ⇒ Object



10
11
12
13
# File 'lib/waqi/client.rb', line 10

def city_feed(city_name)
  response = Service::City.new(city_name).get(token: @token)
  StationData.parse(response)
end

#geo_feed(lat, lon) ⇒ Object



15
16
17
18
# File 'lib/waqi/client.rb', line 15

def geo_feed(lat, lon)
  response = Service::Geolocation.new(lat,lon).get(token: @token)
  StationData.parse(response)
end

#local_feedObject



20
21
22
23
# File 'lib/waqi/client.rb', line 20

def local_feed
  response = Service::City.new().get(token: @token)
  StationData.parse(response)
end

#map_stations(*bounds) ⇒ Object



25
26
27
28
# File 'lib/waqi/client.rb', line 25

def map_stations(*bounds)
  response = Service::Map.new(*bounds).get(token: @token)
  response.map { |data| StationPin.parse(data) }
end

#search(keyword) ⇒ Object



30
31
32
33
# File 'lib/waqi/client.rb', line 30

def search(keyword)
  response = Service::Search.new(keyword).get(token: @token)
  response.map { |data| StationData.parse(data) }
end