class TreeConfig::DeepStruct

Public Class Methods

new(hash=nil) click to toggle source
# File lib/tree_config/vendor/deep_struct.rb, line 3
def initialize(hash=nil)
  @table = {}
  @hash_table = {}

  if hash
    hash.each do |k,v|
      raise KeyIsFixNum if k.instance_of?(Fixnum)
      @table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
      @hash_table[k.to_sym] = v
      new_ostruct_member(k)
    end
  end
end

Public Instance Methods

empty?() click to toggle source
# File lib/tree_config/vendor/deep_struct.rb, line 21
def empty?
  self.hash == 0
end
size() click to toggle source
# File lib/tree_config/vendor/deep_struct.rb, line 25
def size
  sum = 0
  self.each_pair { |p| sum += 1 }
  sum
end
to_h() click to toggle source
# File lib/tree_config/vendor/deep_struct.rb, line 17
def to_h
  @hash_table
end