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.
7709 7710 7711 7712 7713 7714 |
# File 'lib/syntax_tree/node.rb', line 7709 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
7707 7708 7709 |
# File 'lib/syntax_tree/node.rb', line 7707 def comments @comments end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to execute
7701 7702 7703 |
# File 'lib/syntax_tree/node.rb', line 7701 def statement @statement end |
#value ⇒ Object (readonly)
- untyped
-
the value to use if the executed expression raises an error
7704 7705 7706 |
# File 'lib/syntax_tree/node.rb', line 7704 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
7716 7717 7718 |
# File 'lib/syntax_tree/node.rb', line 7716 def accept(visitor) visitor.visit_rescue_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7720 7721 7722 |
# File 'lib/syntax_tree/node.rb', line 7720 def child_nodes [statement, value] end |
#deconstruct_keys(_keys) ⇒ Object
7726 7727 7728 7729 7730 7731 7732 7733 |
# File 'lib/syntax_tree/node.rb', line 7726 def deconstruct_keys(_keys) { statement: statement, value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 |
# File 'lib/syntax_tree/node.rb', line 7735 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 |