Class: OpenStruct

Inherits:
Object
  • Object
show all
Defined in:
lib/cali.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOpenStruct

Returns a new instance of OpenStruct.



31
32
33
# File 'lib/cali.rb', line 31

def initialize
  @hsh = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, value = nil) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/cali.rb', line 23

def method_missing(method, value = nil)
  method = method.to_s
  if method.match(/^(.*)=$/)
    @hsh[$1] = value
  else
    @hsh[method]
  end
end

Instance Attribute Details

#hshObject (readonly)

Returns the value of attribute hsh.



22
23
24
# File 'lib/cali.rb', line 22

def hsh
  @hsh
end