class SyntaxTree::Break

Break represents using the break keyword.

break

It can also optionally accept arguments, as in:

break 1

Attributes

arguments[R]
Args

the arguments being sent to the keyword

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

Public Class Methods

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

Public Instance Methods

===(other) click to toggle source
# File lib/syntax_tree/node.rb, line 2676
def ===(other)
  other.is_a?(Break) && arguments === other.arguments
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 2647
def accept(visitor)
  visitor.visit_break(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 2651
def child_nodes
  [arguments]
end
Also aliased as: deconstruct
copy(arguments: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 2655
def copy(arguments: nil, location: nil)
  node =
    Break.new(
      arguments: arguments || self.arguments,
      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 2668
def deconstruct_keys(_keys)
  { arguments: arguments, location: location, comments: comments }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 2672
def format(q)
  FlowControlFormatter.new("break", self).format(q)
end