Module: KiCad::SExpr::Node3

Defined in:
lib/kicad/grammar.rb

Instance Method Summary collapse

Instance Method Details

#valueObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/kicad/grammar.rb', line 57

def value
  klass_name = values.elements[0].value.value
  klass = KiCad::AST::Node
  if klass_name.is_a? ::Symbol  # See if we have a defined class for this node type
    klass_name = klass_name.to_s.gsub(/\A[a-z]|_[a-z]/) {|from| from[-1].upcase }
    klass = KiCad::AST.const_get(klass_name, false) rescue KiCad::AST::Node
  end
  klass.new values.elements.map(&:value).map(&:value),
            nodes.elements.map(&:node).map(&:value)
end