Class: WeatherApiAssignment::Weather
- Defined in:
- lib/weather_api_assignment/models/weather.rb
Overview
This model contains the weather information
Instance Attribute Summary collapse
-
#description ⇒ String
This field contains the description of weather type in detail.
-
#icon ⇒ String
This field contains icon.
-
#id ⇒ Integer
This field contains the identifier.
-
#main ⇒ String
This field contains the type of weather.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(id = nil, main = nil, description = nil, icon = nil) ⇒ Weather
constructor
A new instance of Weather.
Methods inherited from BaseModel
Constructor Details
#initialize(id = nil, main = nil, description = nil, icon = nil) ⇒ Weather
Returns a new instance of Weather.
35 36 37 38 39 40 41 42 43 |
# File 'lib/weather_api_assignment/models/weather.rb', line 35 def initialize(id = nil, main = nil, description = nil, icon = nil) @id = id @main = main @description = description @icon = icon end |
Instance Attribute Details
#description ⇒ String
This field contains the description of weather type in detail
19 20 21 |
# File 'lib/weather_api_assignment/models/weather.rb', line 19 def description @description end |
#icon ⇒ String
This field contains icon
23 24 25 |
# File 'lib/weather_api_assignment/models/weather.rb', line 23 def icon @icon end |
#id ⇒ Integer
This field contains the identifier
11 12 13 |
# File 'lib/weather_api_assignment/models/weather.rb', line 11 def id @id end |
#main ⇒ String
This field contains the type of weather.
15 16 17 |
# File 'lib/weather_api_assignment/models/weather.rb', line 15 def main @main end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/weather_api_assignment/models/weather.rb', line 46 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash['id'] main = hash['main'] description = hash['description'] icon = hash['icon'] # Create object from extracted values. Weather.new(id, main, description, icon) end |
.names ⇒ Object
A mapping from model property names to API property names.
26 27 28 29 30 31 32 33 |
# File 'lib/weather_api_assignment/models/weather.rb', line 26 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['main'] = 'main' @_hash['description'] = 'description' @_hash['icon'] = 'icon' @_hash end |