Class: ConfParser::Section

Inherits:
Hash
  • Object
show all
Defined in:
lib/confparser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Section

Returns a new instance of Section.



19
20
21
22
# File 'lib/confparser.rb', line 19

def initialize (parent)
  super()
  @parent = parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



17
18
19
# File 'lib/confparser.rb', line 17

def parent
  @parent
end

Instance Method Details

#[](name) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/confparser.rb', line 25

def [] (name)
  __get__(name).tap {|x|
    if x.is_a?(String)
      x.gsub!(/\$\((.+?)\)/) {|n|
        (self[$1] || parent[$1]).to_s
      }
    end
  }
end