Class: SyntaxTree::RescueMod
Overview
RescueMod represents the use of the modifier form of a rescue clause.
expression rescue value
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#statement ⇒ Object
readonly
- untyped
-
the expression to execute.
-
#value ⇒ Object
readonly
- untyped
-
the value to use if the executed expression raises an error.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(statement:, value:, location:, comments: []) ⇒ RescueMod
constructor
A new instance of RescueMod.
Methods inherited from Node
Constructor Details
#initialize(statement:, value:, location:, comments: []) ⇒ RescueMod
Returns a new instance of RescueMod.
7533 7534 7535 7536 7537 7538 |
# File 'lib/syntax_tree/node.rb', line 7533 def initialize(statement:, value:, location:, comments: []) @statement = statement @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7531 7532 7533 |
# File 'lib/syntax_tree/node.rb', line 7531 def comments @comments end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to execute
7525 7526 7527 |
# File 'lib/syntax_tree/node.rb', line 7525 def statement @statement end |
#value ⇒ Object (readonly)
- untyped
-
the value to use if the executed expression raises an error
7528 7529 7530 |
# File 'lib/syntax_tree/node.rb', line 7528 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
7540 7541 7542 |
# File 'lib/syntax_tree/node.rb', line 7540 def accept(visitor) visitor.visit_rescue_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7544 7545 7546 |
# File 'lib/syntax_tree/node.rb', line 7544 def child_nodes [statement, value] end |
#deconstruct_keys(keys) ⇒ Object
7550 7551 7552 7553 7554 7555 7556 7557 |
# File 'lib/syntax_tree/node.rb', line 7550 def deconstruct_keys(keys) { statement: statement, value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 |
# File 'lib/syntax_tree/node.rb', line 7559 def format(q) q.group(0, "begin", "end") do q.indent do q.breakable(force: true) q.format(statement) end q.breakable(force: true) q.text("rescue StandardError") q.indent do q.breakable(force: true) q.format(value) end q.breakable(force: true) end end |