class DtkCommon::DSL::FileParser::InputHash

Public Class Methods

new(hash=nil) click to toggle source

to provide autovification and use of symbol indexes

Calls superclass method
# File lib/dsl/file_parser.rb, line 155
def initialize(hash=nil)
  super()
  return unless hash
  replace_el = hash.inject(Hash.new) do |h,(k,v)|
    processed_v = (v.kind_of?(Hash) ? self.class.new(v) : v)
    h.merge(k =>  processed_v)
  end
  replace(replace_el)
end

Public Instance Methods

[](index) click to toggle source
Calls superclass method
# File lib/dsl/file_parser.rb, line 165
def [](index)
  val = super(internal_key_form(index)) || {}
  (val.kind_of?(Hash) ? self.class.new(val) : val)
end
only_has_keys?(*only_has_keys) click to toggle source
# File lib/dsl/file_parser.rb, line 169
def only_has_keys?(*only_has_keys)
  (keys() - only_has_keys.map{|k|internal_key_form(k)}).empty?
end

Private Instance Methods

internal_key_form(key) click to toggle source
# File lib/dsl/file_parser.rb, line 173
def internal_key_form(key)
  key.to_s
end