class SyntaxTree::PinnedBegin

PinnedBegin represents a pinning a nested statement within pattern matching.

case value
in ^(statement)
end

Attributes

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

statement[R]
Node

the expression being pinned

Public Class Methods

new(statement:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 1969
def initialize(statement:, location:)
  @statement = statement
  @location = location
  @comments = []
end

Public Instance Methods

===(other) click to toggle source
# File lib/syntax_tree/node.rb, line 2014
def ===(other)
  other.is_a?(PinnedBegin) && statement === other.statement
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 1975
def accept(visitor)
  visitor.visit_pinned_begin(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 1979
def child_nodes
  [statement]
end
Also aliased as: deconstruct
copy(statement: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 1983
def copy(statement: nil, location: nil)
  node =
    PinnedBegin.new(
      statement: statement || self.statement,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end
deconstruct()
Alias for: child_nodes
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/node.rb, line 1996
def deconstruct_keys(_keys)
  { statement: statement, location: location, comments: comments }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 2000
def format(q)
  q.group do
    q.text("^(")
    q.nest(1) do
      q.indent do
        q.breakable_empty
        q.format(statement)
      end
      q.breakable_empty
      q.text(")")
    end
  end
end