Class: Prism::RescueModifierNode
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
PrismNode
|
|
|
Instance Chain:
self,
PrismNode
|
|
| Inherits: |
PrismNode
|
| Defined in: | lib/prism/node.rb, ext/prism/api_node.c, lib/prism/parse_result/newlines.rb |
Overview
Represents an expression modified with a rescue.
foo rescue nil
^^^^^^^^^^^^^^
Class Method Summary
-
.new(source, node_id, location, flags, expression, keyword_loc, rescue_expression) ⇒ RescueModifierNode
constructor
Initialize a new
RescueModifierNodenode. -
.type
Return a symbol representation of this node type.
Instance Attribute Summary
-
#expression
readonly
attr_reader expression:
Prism.node -
#rescue_expression
readonly
attr_reader rescue_expression:
Prism.node
Instance Method Summary
-
#===(other)
Implements case-equality for the node.
-
#accept(visitor)
def accept: (Visitor visitor) -> void.
-
#child_nodes
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes
def compact_child_nodes: () -> Array.
- #copy(node_id: self.node_id, location: self.location, flags: self.flags, expression: self.expression, keyword_loc: self.keyword_loc, rescue_expression: self.rescue_expression)
-
#deconstruct
Alias for #child_nodes.
- #deconstruct_keys(keys)
-
#inspect
def inspect -> String.
-
#keyword
def keyword: () -> String.
-
#keyword_loc
attr_reader keyword_loc:
Location. -
#type
Return a symbol representation of this node type.
- #newline_flag!(lines) Internal use only
Constructor Details
.new(source, node_id, location, flags, expression, keyword_loc, rescue_expression) ⇒ RescueModifierNode
Initialize a new RescueModifierNode node.
# File 'lib/prism/node.rb', line 13842
def initialize(source, node_id, location, flags, expression, keyword_loc, rescue_expression) @source = source @node_id = node_id @location = location @flags = flags @expression = expression @keyword_loc = keyword_loc @rescue_expression = rescue_expression end
Class Method Details
.type
Return a symbol representation of this node type. See Node::type.
# File 'lib/prism/node.rb', line 13912
def self.type :rescue_modifier_node end
Instance Attribute Details
#expression (readonly)
attr_reader expression: Prism.node
# File 'lib/prism/node.rb', line 13886
attr_reader :expression
#rescue_expression (readonly)
attr_reader rescue_expression: Prism.node
# File 'lib/prism/node.rb', line 13895
attr_reader :rescue_expression
Instance Method Details
#===(other)
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
# File 'lib/prism/node.rb', line 13918
def ===(other) other.is_a?(RescueModifierNode) && (expression === other.expression) && (keyword_loc.nil? == other.keyword_loc.nil?) && (rescue_expression === other.rescue_expression) end
#accept(visitor)
def accept: (Visitor visitor) -> void
# File 'lib/prism/node.rb', line 13853
def accept(visitor) visitor.visit_rescue_modifier_node(self) end
#child_nodes Also known as: #deconstruct
def child_nodes: () -> Array[nil | Node]
# File 'lib/prism/node.rb', line 13858
def child_nodes [expression, rescue_expression] end
#comment_targets
def comment_targets: () -> Array[Node | Location]
# File 'lib/prism/node.rb', line 13868
def comment_targets [expression, keyword_loc, rescue_expression] #: Array[Prism::node | Location] end
#compact_child_nodes
def compact_child_nodes: () -> Array
# File 'lib/prism/node.rb', line 13863
def compact_child_nodes [expression, rescue_expression] end
#copy(node_id: self.node_id, location: self.location, flags: self.flags, expression: self.expression, keyword_loc: self.keyword_loc, rescue_expression: self.rescue_expression)
# File 'lib/prism/node.rb', line 13873
def copy(node_id: self.node_id, location: self.location, flags: self.flags, expression: self.expression, keyword_loc: self.keyword_loc, rescue_expression: self.rescue_expression) RescueModifierNode.new(source, node_id, location, flags, expression, keyword_loc, rescue_expression) end
#deconstruct
Alias for #child_nodes.
# File 'lib/prism/node.rb', line 13878
alias deconstruct child_nodes
#deconstruct_keys(keys)
# File 'lib/prism/node.rb', line 13881
def deconstruct_keys(keys) { node_id: node_id, location: location, expression: expression, keyword_loc: keyword_loc, rescue_expression: rescue_expression } end
#inspect
def inspect -> String
# File 'lib/prism/node.rb', line 13902
def inspect InspectVisitor.compose(self) end
#keyword
def keyword: () -> String
# File 'lib/prism/node.rb', line 13897
def keyword keyword_loc.slice end
#keyword_loc
attr_reader keyword_loc: Location
#newline_flag!(lines)
# File 'lib/prism/parse_result/newlines.rb', line 116
def newline_flag!(lines) # :nodoc: expression.newline_flag!(lines) end
#type
Return a symbol representation of this node type. See Node#type.
# File 'lib/prism/node.rb', line 13907
def type :rescue_modifier_node end