Class: OpenWeather::Models::Model

Inherits:
Hashie::Trash
  • Object
show all
Includes:
Hashie::Extensions::IgnoreUndeclared, OpenWeather::Models::Mixins::Speed, OpenWeather::Models::Mixins::Temp
Defined in:
lib/open_weather/models/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = nil, options = {}) ⇒ Model

Returns a new instance of Model.



12
13
14
15
16
# File 'lib/open_weather/models/model.rb', line 12

def initialize(args = nil, options = {})
  transformed_args = args.respond_to?(:transform_keys) ? args.transform_keys(&:to_s) : args
  super transformed_args
  @options = { units: OpenWeather.config.units }.merge(options || {})
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/open_weather/models/model.rb', line 10

def options
  @options
end

Instance Method Details

#unitsObject



18
19
20
# File 'lib/open_weather/models/model.rb', line 18

def units
  options && options[:units]&.to_sym
end