Method: O#initialize

Defined in:
lib/o.rb

#initialize(default = nil, options = {}, &blk) ⇒ O

Returns a new instance of O.

Parameters:

  • (nil) (Object)

    default create a new hash with the defalut value



143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/o.rb', line 143

def initialize(default=nil, options={}, &blk)
  @_root = options[:_root]
  @_child = Hash.new(default)

  if blk
    method = _blk2method(&blk)
    if blk.arity == 0
      method.call
    else
      method.call self
    end
  end
end