Class: WeatherApiTask::Main
- Defined in:
- lib/weather_api_task/models/main.rb
Overview
Main Model.
Instance Attribute Summary collapse
-
#feels_like ⇒ Float
TODO: Write general description for this method.
-
#humidity ⇒ Integer
TODO: Write general description for this method.
-
#pressure ⇒ Integer
TODO: Write general description for this method.
-
#temp ⇒ Float
TODO: Write general description for this method.
-
#temp_max ⇒ Float
TODO: Write general description for this method.
-
#temp_min ⇒ Float
TODO: Write general description for this method.
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(temp = nil, feels_like = nil, temp_min = nil, temp_max = nil, pressure = nil, humidity = nil) ⇒ Main
constructor
A new instance of Main.
Methods inherited from BaseModel
Constructor Details
#initialize(temp = nil, feels_like = nil, temp_min = nil, temp_max = nil, pressure = nil, humidity = nil) ⇒ Main
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/weather_api_task/models/main.rb', line 45 def initialize(temp = nil, feels_like = nil, temp_min = nil, temp_max = nil, pressure = nil, humidity = nil) @temp = temp @feels_like = feels_like @temp_min = temp_min @temp_max = temp_max @pressure = pressure @humidity = humidity end |
Instance Attribute Details
#feels_like ⇒ Float
TODO: Write general description for this method
15 16 17 |
# File 'lib/weather_api_task/models/main.rb', line 15 def feels_like @feels_like end |
#humidity ⇒ Integer
TODO: Write general description for this method
31 32 33 |
# File 'lib/weather_api_task/models/main.rb', line 31 def humidity @humidity end |
#pressure ⇒ Integer
TODO: Write general description for this method
27 28 29 |
# File 'lib/weather_api_task/models/main.rb', line 27 def pressure @pressure end |
#temp ⇒ Float
TODO: Write general description for this method
11 12 13 |
# File 'lib/weather_api_task/models/main.rb', line 11 def temp @temp end |
#temp_max ⇒ Float
TODO: Write general description for this method
23 24 25 |
# File 'lib/weather_api_task/models/main.rb', line 23 def temp_max @temp_max end |
#temp_min ⇒ Float
TODO: Write general description for this method
19 20 21 |
# File 'lib/weather_api_task/models/main.rb', line 19 def temp_min @temp_min end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/weather_api_task/models/main.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. temp = hash['temp'] feels_like = hash['feels_like'] temp_min = hash['temp_min'] temp_max = hash['temp_max'] pressure = hash['pressure'] humidity = hash['humidity'] # Create object from extracted values. Main.new(temp, feels_like, temp_min, temp_max, pressure, humidity) end |
.names ⇒ Object
A mapping from model property names to API property names.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/weather_api_task/models/main.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['temp'] = 'temp' @_hash['feels_like'] = 'feels_like' @_hash['temp_min'] = 'temp_min' @_hash['temp_max'] = 'temp_max' @_hash['pressure'] = 'pressure' @_hash['humidity'] = 'humidity' @_hash end |