Module: ATP::AST::Factories

Included in:
Builder, Node
Defined in:
lib/atp/ast/factories.rb

Instance Method Summary collapse

Instance Method Details

#n(type, *children) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/atp/ast/factories.rb', line 4

def n(type, *children)
  options = children.last.is_a?(Hash) ? children.pop : {}
  options[:file] ||= options.delete(:source_file) || try(:source_file)
  options[:line_number] ||= options.delete(:source_line_number) || try(:source_line_number)
  options[:description] ||= options.delete(:description) || try(:description)
  ATP::AST::Node.new(type, children, options)
end

#n0(type, options = {}) ⇒ Object



12
13
14
# File 'lib/atp/ast/factories.rb', line 12

def n0(type, options = {})
  n(type, options)
end