Module: CodeBreaker::Parsable::LanguageElements

Includes:
Node
Included in:
CodeBreaker::Parser
Defined in:
lib/code_breaker/parsable/language_elements.rb

Instance Method Summary collapse

Methods included from Node

#method_missing, #not_implemented_message, #parse, #parse_as_hash, #parse_as_last_child_hash, #parse_as_node_type, #parse_children

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CodeBreaker::Parsable::Node

Instance Method Details

#parse_block_pass_node(node) ⇒ Object



24
25
26
# File 'lib/code_breaker/parsable/language_elements.rb', line 24

def parse_block_pass_node(node)
  { node.type => node.children.first.children.last }
end

#parse_splat_node(node) ⇒ Object



28
29
30
31
32
33
# File 'lib/code_breaker/parsable/language_elements.rb', line 28

def parse_splat_node(node)
  children = parse_children(node).flatten(1)
  values   = children.length == 1 ? children[0] : children

  { node.type => values }
end