class RuboCop::AST::KeywordBeginNode

to all ‘kwbegin` nodes within RuboCop.
node when the builder constructs the AST, making its methods available
A node extension for `kwbegin` nodes. This will be used in place of a plain

def body

Returns:
  • (Node, nil) - The body of the `kwbegin`.
def body
  return unless node_parts.any?
  if rescue_node
    rescue_node.body
  elsif ensure_node
    ensure_node.node_parts[0]
  elsif node_parts.one?
    node_parts[0]
  else
    self
  end
end

def ensure_node

Returns:
  • (Node, nil) - The `rescue` node within `kwbegin`.
def ensure_node
  node_parts[0] if node_parts[0]&.ensure_type?
end

def rescue_node

Returns:
  • (Node, nil) - The `rescue` node within `kwbegin`.
def rescue_node
  return ensure_node&.rescue_node if ensure_node&.rescue_node
  node_parts[0] if node_parts[0]&.rescue_type?
end