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.



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

def initialize(token:)
  @token = token
end

Instance Method Details

#city_feed(city_name) ⇒ Object



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

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

#geo_feed(lat, lon) ⇒ Object



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

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

#local_feedObject



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

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

#map_stations(*bounds) ⇒ Object



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

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

#search(keyword) ⇒ Object



34
35
36
37
# File 'lib/waqi/client.rb', line 34

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

#station_feed(station_id) ⇒ Object



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

def station_feed(station_id)
  response = Service::Station.new(station_id).get(token: @token)
  StationData.parse(response)
end