Class: Rucc::RMap
- Inherits:
-
Object
- Object
- Rucc::RMap
- Defined in:
- lib/rucc/rmap.rb
Overview
RMap – Map with recursive search
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
-
#initialize(parent = nil) ⇒ RMap
constructor
A new instance of RMap.
Constructor Details
#initialize(parent = nil) ⇒ RMap
Returns a new instance of RMap.
5 6 7 8 |
# File 'lib/rucc/rmap.rb', line 5 def initialize(parent = nil) @parent = parent @hash = {} end |
Instance Method Details
#[](k) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/rucc/rmap.rb', line 10 def [](k) v = @hash[k] if v.nil? && !@parent.nil? v = @parent[k] end v end |
#[]=(k, v) ⇒ Object
18 19 20 |
# File 'lib/rucc/rmap.rb', line 18 def []=(k, v) @hash[k] = v end |