Class: Prism::RescueModifierNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::RescueModifierNode
- Defined in:
- lib/prism/node.rb,
lib/prism/parse_result/newlines.rb,
ext/prism/api_node.c
Overview
Represents an expression modified with a rescue.
foo rescue nil
^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
attr_reader expression: Prism::node.
-
#rescue_expression ⇒ Object
readonly
attr_reader rescue_expression: Prism::node.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
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) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?keyword_loc: Location, ?rescue_expression: Prism::node) -> RescueModifierNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, expression: Prism::node, keyword_loc: Location, rescue_expression: Prism::node }.
-
#initialize(source, node_id, location, flags, expression, keyword_loc, rescue_expression) ⇒ RescueModifierNode
constructor
Initialize a new RescueModifierNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#keyword ⇒ Object
def keyword: () -> String.
-
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location.
-
#newline_flag!(lines) ⇒ Object
:nodoc:.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, expression, keyword_loc, rescue_expression) ⇒ RescueModifierNode
Initialize a new RescueModifierNode node.
14091 14092 14093 14094 14095 14096 14097 14098 14099 |
# File 'lib/prism/node.rb', line 14091 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 |
Instance Attribute Details
#expression ⇒ Object (readonly)
attr_reader expression: Prism::node
14135 14136 14137 |
# File 'lib/prism/node.rb', line 14135 def expression @expression end |
#rescue_expression ⇒ Object (readonly)
attr_reader rescue_expression: Prism::node
14145 14146 14147 |
# File 'lib/prism/node.rb', line 14145 def rescue_expression @rescue_expression end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
14163 14164 14165 |
# File 'lib/prism/node.rb', line 14163 def self.type :rescue_modifier_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
14169 14170 14171 14172 14173 14174 |
# File 'lib/prism/node.rb', line 14169 def ===(other) other.is_a?(RescueModifierNode) && (expression === other.expression) && (keyword_loc.nil? == other.keyword_loc.nil?) && (rescue_expression === other.rescue_expression) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
14102 14103 14104 |
# File 'lib/prism/node.rb', line 14102 def accept(visitor) visitor.visit_rescue_modifier_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
14107 14108 14109 |
# File 'lib/prism/node.rb', line 14107 def child_nodes [expression, rescue_expression] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
14117 14118 14119 |
# File 'lib/prism/node.rb', line 14117 def comment_targets [expression, keyword_loc, rescue_expression] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
14112 14113 14114 |
# File 'lib/prism/node.rb', line 14112 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) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?keyword_loc: Location, ?rescue_expression: Prism::node) -> RescueModifierNode
14122 14123 14124 |
# File 'lib/prism/node.rb', line 14122 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_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, expression: Prism::node, keyword_loc: Location, rescue_expression: Prism::node }
14130 14131 14132 |
# File 'lib/prism/node.rb', line 14130 def deconstruct_keys(keys) { node_id: node_id, location: location, expression: expression, keyword_loc: keyword_loc, rescue_expression: rescue_expression } end |
#inspect ⇒ Object
def inspect -> String
14153 14154 14155 |
# File 'lib/prism/node.rb', line 14153 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
14148 14149 14150 |
# File 'lib/prism/node.rb', line 14148 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location
14138 14139 14140 14141 14142 |
# File 'lib/prism/node.rb', line 14138 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#newline_flag!(lines) ⇒ Object
:nodoc:
115 116 117 |
# File 'lib/prism/parse_result/newlines.rb', line 115 def newline_flag!(lines) # :nodoc: expression.newline_flag!(lines) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
14158 14159 14160 |
# File 'lib/prism/node.rb', line 14158 def type :rescue_modifier_node end |