Class: YTools::Path::ChildSelector

Inherits:
Selector
  • Object
show all
Defined in:
lib/ytools/path/selectors.rb

Instance Attribute Summary collapse

Attributes inherited from Selector

#subselector

Instance Method Summary collapse

Methods inherited from Selector

#chain, #chained?

Constructor Details

#initialize(child) ⇒ ChildSelector

Returns a new instance of ChildSelector.



27
28
29
# File 'lib/ytools/path/selectors.rb', line 27

def initialize(child)
  @child = child
end

Instance Attribute Details

#childObject (readonly)

Returns the value of attribute child.



25
26
27
# File 'lib/ytools/path/selectors.rb', line 25

def child
  @child
end

Instance Method Details

#select(yaml) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ytools/path/selectors.rb', line 31

def select(yaml)
  if yaml.yhash.has_key?(child)
    value = yaml[child]
    if chained?
      subselector.select(value)
    else
      value
    end
  else
    nil
  end
end