class Pollution
Public Class Methods
Public Instance Methods
city(cityname)
click to toggle source
> Returns the air pollution data of the given city or throws an error if the city wasn't found.¶ ↑
# File lib/pollution.rb, line 19 def city(cityname) data = JSON.parse(Net::HTTP.get('api.waqi.info', "/feed/#{cityname}/?token=#{@token}")) if data['status'] == 'error' raise data['data'] else return data end end
geo(latitude, longitude)
click to toggle source
> Returns the air pollution data of the given coordinates.¶ ↑
# File lib/pollution.rb, line 45 def geo(latitude, longitude) data = JSON.parse(Net::HTTP.get('api.waqi.info', "/feed/geo:#{latitude};#{longitude}/?token=#{@token}")) if data['status'] == 'error' raise data['data'] else return data end end
here()
click to toggle source
map(latitude_min, longitude_min, latitude_max, longitude_max)
click to toggle source
> Returns the air pollution data of the area between the given coordinates. This method takes 4 arguments: Latitude 1, Longitude 1, Latitude 2, Longitude 2.¶ ↑
# File lib/pollution.rb, line 58 def map(latitude_min, longitude_min, latitude_max, longitude_max) latlng = latitude_min.to_s + longitude_min.to_s + latitude_max.to_s + longitude_max.to_s data = JSON.parse(Net::HTTP.get('api.waqi.info', "/map/bounds/?token=#{@token}&latlng=#{latlng}")) if data['status'] == 'error' raise data['data'] else return data end end
search(keyword)
click to toggle source