Class: Rucc::RMap

Inherits:
Object
  • Object
show all
Defined in:
lib/rucc/rmap.rb

Overview

RMap – Map with recursive search

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ RMap

Returns a new instance of RMap.

Parameters:

  • parent (RMap, NilClass) (defaults to: nil)


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