class Querly::NodePair

Attributes

node[R]
parent[R]

Public Class Methods

new(node:, parent: nil) click to toggle source
# File lib/querly/node_pair.rb, line 6
def initialize(node:, parent: nil)
  @node = node
  @parent = parent
end

Public Instance Methods

children() click to toggle source
# File lib/querly/node_pair.rb, line 11
def children
  node.children.flat_map do |child|
    if child.is_a?(Parser::AST::Node)
      self.class.new(node: child, parent: self)
    else
      []
    end
  end
end
each_subpair() { |self| ... } click to toggle source
# File lib/querly/node_pair.rb, line 21
def each_subpair(&block)
  if block_given?
    return unless node

    yield self

    children.each do |child|
      child.each_subpair(&block)
    end
  else
    enum_for :each_subpair
  end
end