Module: Ruby::Alternation::Hash
- Included in:
- Hash
- Defined in:
- lib/ruby/alternation/hash.rb
Instance Method Summary collapse
Instance Method Details
#[](key) ⇒ Object
4 5 6 |
# File 'lib/ruby/alternation/hash.rb', line 4 def [](key) each { |assoc| return assoc.value if assoc.key.value == key } or nil end |
#[]=(key, value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ruby/alternation/hash.rb', line 8 def []=(key, value) value = Ruby.from_native(value, nil, ' ') unless value.is_a?(Node) if assoc = detect { |assoc| assoc.key.value == key } assoc.value = value else # # TODO never happens, fix positions # separators << Token.new(',') # elements << Assoc.new(key, value) # self[key] end end |
#delete(key) ⇒ Object
20 21 22 |
# File 'lib/ruby/alternation/hash.rb', line 20 def delete(key) delete_if { |assoc| assoc.key.value == key } end |