| Class | OHash |
| In: |
lib/o_hash.rb
|
| Parent: | Hash |
| keys | -> | unordered_keys |
| order | [RW] |
# File lib/o_hash.rb, line 179 def self.[] ( *args ) hsh = OHash.new if Hash === args[0] hsh.replace args[0] elsif (args.size % 2) != 0 raise ArgumentError, "odd number of elements for Hash" else hsh[args.shift] = args.shift while args.size > 0 end hsh end
# File lib/o_hash.rb, line 193 def self.yaml_load ( val ) case val when Hash return OHash[val.to_a] when OHash return val when Array if val.all? { |x| x.is_a?(Hash) and x.size == 1 } h = OHash.new val.each do |x| k, v = x h[k] = v end return h end end raise ArgumentError, "Cannot create a OHash with `#{val}'" end