Class: DtkCommon::DSL::FileParser::InputHash
- Inherits:
-
Hash
- Object
- Hash
- DtkCommon::DSL::FileParser::InputHash
- Defined in:
- lib/dsl/file_parser.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#initialize(hash = nil) ⇒ InputHash
constructor
to provide autovification and use of symbol indexes.
- #only_has_keys?(*only_has_keys) ⇒ Boolean
Constructor Details
#initialize(hash = nil) ⇒ InputHash
to provide autovification and use of symbol indexes
139 140 141 142 143 144 145 146 147 |
# File 'lib/dsl/file_parser.rb', line 139 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 |
Instance Method Details
#[](index) ⇒ Object
149 150 151 152 |
# File 'lib/dsl/file_parser.rb', line 149 def [](index) val = super(internal_key_form(index)) || {} (val.kind_of?(Hash) ? self.class.new(val) : val) end |
#only_has_keys?(*only_has_keys) ⇒ Boolean
153 154 155 |
# File 'lib/dsl/file_parser.rb', line 153 def only_has_keys?(*only_has_keys) (keys() - only_has_keys.map{|k|internal_key_form(k)}).empty? end |