Class: WeatherApiAssignment::Sys
- Defined in:
- lib/weather_api_assignment/models/sys.rb
Overview
This model contains the country, sunset and sunrise information.
Instance Attribute Summary collapse
-
#country ⇒ String
This field contains the country code.
-
#id ⇒ Integer
This field contains the identifier.
-
#message ⇒ Float
This field contains the information message.
-
#sunrise ⇒ Long
This field contains the information of sunrise in given city.
-
#sunset ⇒ Long
This field contains the information of sunset in given city.
-
#type ⇒ Integer
This field contains the type of information.
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(sunrise = nil, sunset = nil, type = nil, id = nil, message = nil, country = nil) ⇒ Sys
constructor
A new instance of Sys.
Methods inherited from BaseModel
Constructor Details
#initialize(sunrise = nil, sunset = nil, type = nil, id = nil, message = nil, country = nil) ⇒ Sys
Returns a new instance of Sys.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/weather_api_assignment/models/sys.rb', line 45 def initialize(sunrise = nil, sunset = nil, type = nil, id = nil, = nil, country = nil) @type = type @id = id @message = @country = country @sunrise = sunrise @sunset = sunset end |
Instance Attribute Details
#country ⇒ String
This field contains the country code
23 24 25 |
# File 'lib/weather_api_assignment/models/sys.rb', line 23 def country @country end |
#id ⇒ Integer
This field contains the identifier
15 16 17 |
# File 'lib/weather_api_assignment/models/sys.rb', line 15 def id @id end |
#message ⇒ Float
This field contains the information message
19 20 21 |
# File 'lib/weather_api_assignment/models/sys.rb', line 19 def @message end |
#sunrise ⇒ Long
This field contains the information of sunrise in given city
27 28 29 |
# File 'lib/weather_api_assignment/models/sys.rb', line 27 def sunrise @sunrise end |
#sunset ⇒ Long
This field contains the information of sunset in given city
31 32 33 |
# File 'lib/weather_api_assignment/models/sys.rb', line 31 def sunset @sunset end |
#type ⇒ Integer
This field contains the type of information
11 12 13 |
# File 'lib/weather_api_assignment/models/sys.rb', line 11 def type @type 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_assignment/models/sys.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. sunrise = hash['sunrise'] sunset = hash['sunset'] type = hash['type'] id = hash['id'] = hash['message'] country = hash['country'] # Create object from extracted values. Sys.new(sunrise, sunset, type, id, , country) 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_assignment/models/sys.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['type'] = 'type' @_hash['id'] = 'id' @_hash['message'] = 'message' @_hash['country'] = 'country' @_hash['sunrise'] = 'sunrise' @_hash['sunset'] = 'sunset' @_hash end |