Class: OpenMeteo::Entities::Forecast::Units

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

Overview

A forecast entity for data units returned by OpenMeteo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_units) ⇒ Units

Returns a new instance of Units.



9
10
11
12
13
14
# File 'lib/open_meteo/entities/forecast/units.rb', line 9

def initialize(json_units)
  @raw_json_units = json_units

  @attributes = json_units.keys
  @time = json_units["time"]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



18
19
20
21
22
23
24
# File 'lib/open_meteo/entities/forecast/units.rb', line 18

def method_missing(name, *args)
  if raw_json_units.key?(name.to_s)
    raw_json_units[name.to_s]
  else
    super
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



7
8
9
# File 'lib/open_meteo/entities/forecast/units.rb', line 7

def attributes
  @attributes
end

#raw_json_unitsObject (readonly)

Returns the value of attribute raw_json_units.



7
8
9
# File 'lib/open_meteo/entities/forecast/units.rb', line 7

def raw_json_units
  @raw_json_units
end

#timeObject (readonly)

Returns the value of attribute time.



7
8
9
# File 'lib/open_meteo/entities/forecast/units.rb', line 7

def time
  @time
end