module Unparser::NodeHelpers
Public Instance Methods
n(type, children = [])
click to toggle source
Helper for building nodes
@param [Symbol] type
@return [Parser::AST::Node] @param [Array] children
@api private
# File lib/unparser/node_helpers.rb, line 26 def n(type, children = []) Parser::AST::Node.new(type, children) end
n?(type, node)
click to toggle source
# File lib/unparser/node_helpers.rb, line 30 def n?(type, node) node.type.equal?(type) end
s(type, *children)
click to toggle source
Helper for building nodes
@param [Symbol] type @param [Parser::AST::Node] children
@return [Parser::AST::Node]
@api private
# File lib/unparser/node_helpers.rb, line 14 def s(type, *children) Parser::AST::Node.new(type, children) end
unwrap_single_begin(node)
click to toggle source
# File lib/unparser/node_helpers.rb, line 69 def unwrap_single_begin(node) if n_begin?(node) && node.children.one? node.children.first else node end end