weatherfor 0.1.0 → 0.1.1
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/Gemfile.lock +1 -1
- data/lib/weatherfor.rb +16 -3
- data/lib/weatherfor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d91081045d7f71e401a73bb0dc6aa7cbd706e01a36ee249ecd7613752a6596bc
|
4
|
+
data.tar.gz: 7d62a6c77ad4c31b081e06ef3a7dedf2a2e3817832ae3a37401bc1052bae78b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2fa9381e3eb2feb64523ccbeef5122633e62a7e1dcb2c9a8b6f83120c18679e33084e963fbd1abb33f0450e3b020c9d659b741db18c8f5629f267aa9b6a6ab9
|
7
|
+
data.tar.gz: 01b1a2dde2cafd068a1c787b4b745c792f98f4efbc608f49a6ce8f0aa09749fc7dd97f21abe64276341e90b7fce5af1a5de9e8b4d92dc8740416bbe9dc10d9e6
|
data/Gemfile.lock
CHANGED
data/lib/weatherfor.rb
CHANGED
@@ -28,19 +28,32 @@ module Weatherfor
|
|
28
28
|
def weather_in_days
|
29
29
|
arr = []
|
30
30
|
@json['list'].group_by{ |item| Time.at(item['dt']).strftime("%m-%d-%Y") }.each do |date,data|
|
31
|
-
avg_temp = data.
|
31
|
+
avg_temp = data.sum { |info| info['main']['temp'] }
|
32
32
|
avg_temp = avg_temp / 8
|
33
33
|
arr << { avg_temp: avg_temp, date: date }
|
34
34
|
end
|
35
|
+
|
36
|
+
parse_avg_text(arr)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def parse_avg_text(arr)
|
35
42
|
current_temp = @json['list'][0]['main']['temp']
|
36
43
|
city_name = @json['city']['name']
|
37
44
|
weather_description = @json['list'][0]['weather'][0]['description']
|
38
45
|
current_date = arr.first[:date].gsub('-', '/').delete_suffix('/2021')
|
39
46
|
text = "#{current_temp.round(0)}°C e #{weather_description} em #{city_name} em #{current_date}. Média para os próximos dias: "
|
40
47
|
|
41
|
-
arr.last(4).
|
42
|
-
text += "#{item[:avg_temp].round(0)}°C em #{item[:date].gsub('-', '/').delete_suffix('/2021')}
|
48
|
+
arr.last(4).each_with_index do |item, index|
|
49
|
+
text += "#{item[:avg_temp].round(0)}°C em #{item[:date].gsub('-', '/').delete_suffix('/2021')}"
|
50
|
+
if index < 3
|
51
|
+
text += ", "
|
52
|
+
else
|
53
|
+
text += "."
|
54
|
+
end
|
43
55
|
end
|
56
|
+
|
44
57
|
text
|
45
58
|
end
|
46
59
|
end
|
data/lib/weatherfor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weatherfor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caio Ramos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Sumario
|
14
14
|
email:
|