5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/meteoservice/read_data.rb', line 5
def self.from_array(doc)
include Meteoservice::Constants
forecasts = doc.map do |prediction|
predict_data = {}
data = KEYS_DATA.map do |key|
prediction[key].to_i
end
predict_data[:data] = data
phenomena = KEYS_PHENOMENA.map do |key|
prediction['PHENOMENA'][key].to_i
end
predict_data[:phenomena] = phenomena
pressure = KEYS_LIMIT.map do |key|
prediction['PRESSURE'][key].to_i
end
predict_data[:pressure] = pressure
temperature = KEYS_LIMIT.map do |key|
prediction['TEMPERATURE'][key].to_i
end
predict_data[:temperature] = temperature
relwet = KEYS_LIMIT.map do |key|
prediction['RELWET'][key].to_i
end
predict_data[:relwet] = relwet
heat = KEYS_LIMIT.map do |key|
prediction['HEAT'][key].to_i
end
predict_data[:heat] = heat
max_wind = prediction['WIND']['max']
min_wind = prediction['WIND']['min']
direction_wind = prediction['WIND']['direction']
predict_data[:wind] = [min_wind, max_wind, direction_wind]
Meteoservice::Meteo.new(predict_data)
end
new(forecasts)
end
|