Class: OpenMeteo::Entities::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/open_meteo/entities/search.rb

Overview

A list of possible locations from the Geocoding API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_body) ⇒ Search

Returns a new instance of Search.



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/open_meteo/entities/search.rb', line 35

def initialize(json_body)
  @raw_json = json_body

  @results =
    json_body["results"].map do |result|
      normalized_result = result.transform_keys { |key| key.to_s.gsub(/(\w)(\d)/, '\1_\2') }

      SearchResult.new(normalized_result)
    end
  @attributes = json_body.keys
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



33
34
35
# File 'lib/open_meteo/entities/search.rb', line 33

def attributes
  @attributes
end

#raw_jsonObject (readonly)

Returns the value of attribute raw_json.



33
34
35
# File 'lib/open_meteo/entities/search.rb', line 33

def raw_json
  @raw_json
end

#resultsObject (readonly)

Returns the value of attribute results.



33
34
35
# File 'lib/open_meteo/entities/search.rb', line 33

def results
  @results
end