class YARP::RescueModifierNode

Represents an expression modified with a rescue.

foo rescue nil
^^^^^^^^^^^^^^

Attributes

expression[R]

attr_reader expression: Node

keyword_loc[R]

attr_reader keyword_loc: Location

rescue_expression[R]

attr_reader rescue_expression: Node

Public Class Methods

new(expression, keyword_loc, rescue_expression, location) click to toggle source

def initialize: (expression: Node, keyword_loc: Location, rescue_expression: Node, location: Location) -> void

# File yarp/node.rb, line 9139
def initialize(expression, keyword_loc, rescue_expression, location)
  @expression = expression
  @keyword_loc = keyword_loc
  @rescue_expression = rescue_expression
  @location = location
end

Public Instance Methods

accept(visitor) click to toggle source

def accept: (visitor: Visitor) -> void

# File yarp/node.rb, line 9147
def accept(visitor)
  visitor.visit_rescue_modifier_node(self)
end
child_nodes() click to toggle source

def child_nodes: () -> Array[nil | Node]

# File yarp/node.rb, line 9156
def child_nodes
  [expression, rescue_expression]
end
Also aliased as: deconstruct
comment_targets() click to toggle source

def comment_targets: () -> Array[Node | Location]

# File yarp/node.rb, line 9161
def comment_targets
  [expression, keyword_loc, rescue_expression]
end
copy(**params) click to toggle source

def copy: (**params) -> RescueModifierNode

# File yarp/node.rb, line 9166
def copy(**params)
  RescueModifierNode.new(
    params.fetch(:expression) { expression },
    params.fetch(:keyword_loc) { keyword_loc },
    params.fetch(:rescue_expression) { rescue_expression },
    params.fetch(:location) { location },
  )
end
deconstruct()

def deconstruct: () -> Array[nil | Node]

Alias for: child_nodes
deconstruct_keys(keys) click to toggle source

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]

# File yarp/node.rb, line 9179
def deconstruct_keys(keys)
  { expression: expression, keyword_loc: keyword_loc, rescue_expression: rescue_expression, location: location }
end
inspect(inspector = NodeInspector.new) click to toggle source
# File yarp/node.rb, line 9188
def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  inspector << "├── expression:\n"
  inspector << inspector.child_node(expression, "│   ")
  inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n"
  inspector << "└── rescue_expression:\n"
  inspector << inspector.child_node(rescue_expression, "    ")
  inspector.to_str
end
keyword() click to toggle source

def keyword: () -> String

# File yarp/node.rb, line 9184
def keyword
  keyword_loc.slice
end
set_newline_flag(newline_marked) click to toggle source
# File yarp/node.rb, line 9151
def set_newline_flag(newline_marked)
  expression.set_newline_flag(newline_marked)
end