Class: KNMI::Calculations

Inherits:
Object
  • Object
show all
Defined in:
lib/knmi/calculations.rb

Class Method Summary collapse

Class Method Details

.convert_daily(array) ⇒ Array<Hash>

Converts Daily KNMI.get_data().data from storage to operable units

Parameters:

  • array (Array<Hash>)
    • in storage format (integers)

Returns:

  • (Array<Hash>)
    • in operable format (Float, Integer, Time)



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/knmi/calculations.rb', line 9

def convert_daily(array)
  x = []
  
  array.each_with_index do |a, index|
    x[index] = {}
    x[index][:STN] = a[:STN]
    a.each_pair { |key,value| x[index].merge!( {key => converts_daily(key, value)} ) }
  
  end
  
  return x          
end

.convert_hourly(array) ⇒ Array<Hash>

Converts Hourly KNMI.get_data().data from storage to operable units

Parameters:

  • array (Array<Hash>)
    • Array of hashes, in storage format (integers)

Returns:

  • (Array<Hash>)
    • Array of hashes, in operable format (Float, Integer, Time)



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/knmi/calculations.rb', line 26

def convert_hourly(array)
  x = []
  
  array.each_with_index do |a, index|
    x[index] = {}
    x[index][:STN] = a[:STN]
    a.each_pair { |key,value| x[index].merge!( {key => converts_daily(key, value)} ) }
    x[index][:Time] = x[index][:YYYYMMDD] + x[index][:HH]
    
  end
  
  return x
end