class OpenMeteoResponse
Public Class Methods
new(relevant_attributes)
click to toggle source
# File lib/open_meteo_client/open_meteo_response.rb, line 5 def initialize(relevant_attributes) @json_response = '' @relevant_attributes = relevant_attributes end
Public Instance Methods
append_line(line)
click to toggle source
# File lib/open_meteo_client/open_meteo_response.rb, line 10 def append_line(line) @json_response += line unless line.nil? end
as_hash()
click to toggle source
# File lib/open_meteo_client/open_meteo_response.rb, line 14 def as_hash complete_hash = JSON.parse @json_response, :symbolize_names => true complete_hash.keep_if {|key, value| @relevant_attributes.include?(key)} end
as_list()
click to toggle source
# File lib/open_meteo_client/open_meteo_response.rb, line 23 def as_list response_hash = as_hash forecasts = [] response_hash.each_pair { |key, value| if value.is_a?(Array) value.each_with_index do |val, i| forecasts[i] ||= {} forecasts[i][key] = val end end } forecasts end
as_raw_json()
click to toggle source
# File lib/open_meteo_client/open_meteo_response.rb, line 19 def as_raw_json @json_response end