Class: WeatherLink::HashWrapper

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/weatherlink/hash_wrapper.rb

Direct Known Subclasses

DataRecord, Node, Sensor, SensorRecord, Station

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ HashWrapper

Returns a new instance of HashWrapper.



9
10
11
12
# File 'lib/weatherlink/hash_wrapper.rb', line 9

def initialize(data)
  @data = data
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



16
17
18
19
20
# File 'lib/weatherlink/hash_wrapper.rb', line 16

def method_missing(symbol, *args)
  return data.fetch(symbol.to_s) if data.include?(symbol.to_s)

  super
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/weatherlink/hash_wrapper.rb', line 7

def data
  @data
end