easy_weather 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/easy_weather/version.rb +1 -1
- data/lib/easy_weather/weather.rb +12 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1c944ba34e8396104184ad4812e8e322e8a5490e9515382dcc63f09df6a7093
|
4
|
+
data.tar.gz: fb72697157738cd53967926e2f5dc843cf12e7b9b29c7fc593f727b53d214def
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79f63d06e494c313cc5c9155f2057555fabd09fe082103fdf63680ecfbed10eab461fa1e53340744207f8fb1ebec151ef94ffc3bc9f5245a8ff6a60b05d3d72c
|
7
|
+
data.tar.gz: a34f4aece0c1d549a9cc501a5eacd12ad680490610b21153a6af74c88fb78da736f61369b4520e51f007e473f789365533615202a196f9a830b7257bdb24370b
|
data/lib/easy_weather/version.rb
CHANGED
data/lib/easy_weather/weather.rb
CHANGED
@@ -41,24 +41,26 @@ class Weather
|
|
41
41
|
pressure: data["main"]["pressure"],
|
42
42
|
visibility: data["visibility"]
|
43
43
|
}
|
44
|
-
"Humidy: #{data_hash[:humidity]}%, pressure: #{data_hash[:pressure]}hPa,
|
44
|
+
"Humidy: #{data_hash[:humidity]}%, pressure: #{data_hash[:pressure]}hPa,
|
45
|
+
visibility: #{data_hash[:visibility]} meters"
|
45
46
|
end
|
46
47
|
|
47
48
|
private
|
48
49
|
|
49
50
|
def get_general_data(city)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
JSON.parse(response.body)
|
51
|
+
url = "#{BASE_URL}weather?q=#{city}
|
52
|
+
&units=metric&APPID=#{ENV["EASY_WEATHER"]}"
|
53
|
+
fetch_data(url)
|
55
54
|
end
|
56
55
|
|
57
56
|
def get_forecast_data(days, city)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
url = "#{BASE_URL}forecast?q=#{city}
|
58
|
+
&units=metric&cnt=#{days}&appid=#{ENV["EASY_WEATHER"]}"
|
59
|
+
fetch_data(url)
|
60
|
+
end
|
61
|
+
|
62
|
+
def fetch_data(url)
|
63
|
+
response = HTTParty.get(url)
|
62
64
|
JSON.parse(response.body)
|
63
65
|
end
|
64
66
|
end
|