Module: Unparser::NodeHelpers
- Included in:
- Emitter, NodeDetails, Writer
- Defined in:
- lib/unparser/node_helpers.rb
Instance Method Summary collapse
-
#n(type, children = []) ⇒ Parser::AST::Node
private
Helper for building nodes.
- #n?(type, node) ⇒ Boolean
-
#s(type, *children) ⇒ Parser::AST::Node
private
Helper for building nodes.
- #unwrap_single_begin(node) ⇒ Object
Instance Method Details
#n(type, children = []) ⇒ Parser::AST::Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Helper for building nodes
26 27 28 |
# File 'lib/unparser/node_helpers.rb', line 26 def n(type, children = []) Parser::AST::Node.new(type, children) end |
#n?(type, node) ⇒ Boolean
30 31 32 |
# File 'lib/unparser/node_helpers.rb', line 30 def n?(type, node) node.type.equal?(type) end |
#s(type, *children) ⇒ Parser::AST::Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Helper for building nodes
14 15 16 |
# File 'lib/unparser/node_helpers.rb', line 14 def s(type, *children) Parser::AST::Node.new(type, children) end |
#unwrap_single_begin(node) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/unparser/node_helpers.rb', line 72 def unwrap_single_begin(node) if n_begin?(node) && node.children.one? node.children.first else node end end |