air-pollution-gem 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pollution.rb +22 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67fd26a7cd72f197d5350b116a418b7bc18a9cd0a707e36108dc7c816c336f7a
|
4
|
+
data.tar.gz: aad7425bba719a0dde1bb514988b380f6eea9f2d5f5b4c2e0133081a65884bd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c37c75d588c56b0ba05bebbd69adae6fb220e1be496b20c118fc387482ec1fc7abecb1cf0a7f6cff2a05f7915c3ec920228f5a6689c31bf5dd848ce865b0552a
|
7
|
+
data.tar.gz: 7d1fb6970935504b526c6dd1f5947b1d3a34fef7bbed312383f34ef254cfa389f430b2dcdb62f3d1e492fb30a343ddee7657867a3b647a4b01245060840ea21d
|
data/lib/pollution.rb
CHANGED
@@ -5,10 +5,17 @@ class Pollution
|
|
5
5
|
|
6
6
|
@token
|
7
7
|
|
8
|
+
##
|
9
|
+
# => Initialize the Pollution class and set the token variable.
|
10
|
+
##
|
8
11
|
def initialize(token)
|
9
12
|
@token = token
|
10
13
|
end
|
11
14
|
|
15
|
+
##
|
16
|
+
# => Returns the air pollution data of the given city or throws an error if the city wasn't found.
|
17
|
+
##
|
18
|
+
|
12
19
|
def city(cityname)
|
13
20
|
data = JSON.parse(Net::HTTP.get('api.waqi.info', "/feed/#{cityname}/?token=#{@token}"))
|
14
21
|
if data['status'] == 'error'
|
@@ -18,6 +25,10 @@ class Pollution
|
|
18
25
|
end
|
19
26
|
end
|
20
27
|
|
28
|
+
##
|
29
|
+
# => Returns the air pollution data of the current location (IP Based).
|
30
|
+
##
|
31
|
+
|
21
32
|
def here
|
22
33
|
data = JSON.parse(Net::HTTP.get('api.waqi.info', "/feed/here/?token=#{@token}"))
|
23
34
|
if data['status'] == 'error'
|
@@ -27,14 +38,9 @@ class Pollution
|
|
27
38
|
end
|
28
39
|
end
|
29
40
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
raise data['data']
|
34
|
-
else
|
35
|
-
return data
|
36
|
-
end
|
37
|
-
end
|
41
|
+
##
|
42
|
+
# => Returns the air pollution data of the given coordinates.
|
43
|
+
##
|
38
44
|
|
39
45
|
def geo(latitude, longitude)
|
40
46
|
data = JSON.parse(Net::HTTP.get('api.waqi.info', "/feed/geo:#{latitude};#{longitude}/?token=#{@token}"))
|
@@ -45,6 +51,10 @@ class Pollution
|
|
45
51
|
end
|
46
52
|
end
|
47
53
|
|
54
|
+
##
|
55
|
+
# => 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.
|
56
|
+
##
|
57
|
+
|
48
58
|
def map(latitude_min, longitude_min, latitude_max, longitude_max)
|
49
59
|
latlng = latitude_min.to_s + longitude_min.to_s + latitude_max.to_s + longitude_max.to_s
|
50
60
|
data = JSON.parse(Net::HTTP.get('api.waqi.info', "/map/bounds/?token=#{@token}&latlng=#{latlng}"))
|
@@ -55,6 +65,10 @@ class Pollution
|
|
55
65
|
end
|
56
66
|
end
|
57
67
|
|
68
|
+
##
|
69
|
+
# => Returns data about stations near the searched keyword.
|
70
|
+
##
|
71
|
+
|
58
72
|
def search(keyword)
|
59
73
|
data = JSON.parse(Net::HTTP.get('api.waqi.info', "/search/?keyword=#{keyword}&token=#{@token}"))
|
60
74
|
if data['status'] == 'error'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: air-pollution-gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cosimo Libutti
|
@@ -23,8 +23,8 @@ homepage: https://rubygems.org/gems/example
|
|
23
23
|
licenses:
|
24
24
|
- MIT
|
25
25
|
metadata:
|
26
|
-
source_code_uri: https://github.com/
|
27
|
-
api_docs: https://
|
26
|
+
source_code_uri: https://github.com/3llish/air-pollution-gem
|
27
|
+
api_docs: https://github.com/3llish/air-pollution-gem
|
28
28
|
post_install_message:
|
29
29
|
rdoc_options: []
|
30
30
|
require_paths:
|