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.
6991 6992 6993 6994 6995 6996 |
# File 'lib/syntax_tree/node.rb', line 6991 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
6989 6990 6991 |
# File 'lib/syntax_tree/node.rb', line 6989 def comments @comments end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to execute
6983 6984 6985 |
# File 'lib/syntax_tree/node.rb', line 6983 def statement @statement end |
#value ⇒ Object (readonly)
- untyped
-
the value to use if the executed expression raises an error
6986 6987 6988 |
# File 'lib/syntax_tree/node.rb', line 6986 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
6998 6999 7000 |
# File 'lib/syntax_tree/node.rb', line 6998 def accept(visitor) visitor.visit_rescue_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7002 7003 7004 |
# File 'lib/syntax_tree/node.rb', line 7002 def child_nodes [statement, value] end |
#deconstruct_keys(keys) ⇒ Object
7008 7009 7010 7011 7012 7013 7014 7015 |
# File 'lib/syntax_tree/node.rb', line 7008 def deconstruct_keys(keys) { statement: statement, value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 |
# File 'lib/syntax_tree/node.rb', line 7017 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 |