Class: Musterb::HashExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/musterb/hash_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, parent) ⇒ HashExtractor

Returns a new instance of HashExtractor.



6
7
8
9
# File 'lib/musterb/hash_extractor.rb', line 6

def initialize(value, parent)    
  @value = to_string_access(value)
  @parent = parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



4
5
6
# File 'lib/musterb/hash_extractor.rb', line 4

def parent
  @parent
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/musterb/hash_extractor.rb', line 4

def value
  @value
end

Instance Method Details

#[](symbol) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/musterb/hash_extractor.rb', line 11

def [](symbol)
  if @value.has_key? symbol
    @value[symbol]
  else
    @parent[symbol]
  end
end