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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(statement:, value:, location:, comments: []) ⇒ RescueMod
Returns a new instance of RescueMod.
7633 7634 7635 7636 7637 7638 |
# File 'lib/syntax_tree/node.rb', line 7633 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
7631 7632 7633 |
# File 'lib/syntax_tree/node.rb', line 7631 def comments @comments end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to execute
7625 7626 7627 |
# File 'lib/syntax_tree/node.rb', line 7625 def statement @statement end |
#value ⇒ Object (readonly)
- untyped
-
the value to use if the executed expression raises an error
7628 7629 7630 |
# File 'lib/syntax_tree/node.rb', line 7628 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
7640 7641 7642 |
# File 'lib/syntax_tree/node.rb', line 7640 def accept(visitor) visitor.visit_rescue_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7644 7645 7646 |
# File 'lib/syntax_tree/node.rb', line 7644 def child_nodes [statement, value] end |
#deconstruct_keys(_keys) ⇒ Object
7650 7651 7652 7653 7654 7655 7656 7657 |
# File 'lib/syntax_tree/node.rb', line 7650 def deconstruct_keys(_keys) { statement: statement, value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 |
# File 'lib/syntax_tree/node.rb', line 7659 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 |