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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pollution.rb +22 -8
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3d94869a1ac8267d23b102c972bd7d2e2984364855be0f7d0606799a7125124
4
- data.tar.gz: dfc7071e4981cded9fd10b4d12b899a27c376c0f61194b5e50ceab7612adecd3
3
+ metadata.gz: 67fd26a7cd72f197d5350b116a418b7bc18a9cd0a707e36108dc7c816c336f7a
4
+ data.tar.gz: aad7425bba719a0dde1bb514988b380f6eea9f2d5f5b4c2e0133081a65884bd3
5
5
  SHA512:
6
- metadata.gz: 52db1bfc7c864ab8cf55782e6eca6e61620de88d928d784ecd060f59c5360df340ae0bc074cde831ec47ae5bb307bebfc4562022576c1e37dae7c824c0b0a965
7
- data.tar.gz: d50cb6c4c7ff67f943ca641bfadbc37de233eab6c556e8c08f54c29a3eabb2cfebd05b3b619d15e165bcf6a98e676946471be7b323f56d418ba1716a061e3cbc
6
+ metadata.gz: c37c75d588c56b0ba05bebbd69adae6fb220e1be496b20c118fc387482ec1fc7abecb1cf0a7f6cff2a05f7915c3ec920228f5a6689c31bf5dd848ce865b0552a
7
+ data.tar.gz: 7d1fb6970935504b526c6dd1f5947b1d3a34fef7bbed312383f34ef254cfa389f430b2dcdb62f3d1e492fb30a343ddee7657867a3b647a4b01245060840ea21d
@@ -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
- def geo(latitude, longitude)
31
- data = JSON.parse(Net::HTTP.get('api.waqi.info', "/feed/geo:#{latitude};#{longitude}/?token=#{@token}"))
32
- if data['status'] == 'error'
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.1
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/example/example
27
- api_docs: https://aqicn.org/json-api/doc/
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: