class SymbolHash

def self.[](*hsh)

Returns:
  • (SymbolHash) - a new SymbolHash object
  • (SymbolHash) - a new SymbolHash from a hash object

Parameters:
  • list (Array) -- an even list of key followed by value
  • hash (Hash) -- the hash object

Overloads:
  • [](*list)
  • [](hash)
def self.[](*hsh)
  obj = new
  if hsh.size == 1 && hsh.first.is_a?(Hash)
    hsh.first.each {|k, v| obj[k] = v }
  else
    0.step(hsh.size, 2) {|n| obj[hsh[n]] = hsh[n + 1] }
  end
  obj
end