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.
8007 8008 8009 8010 8011 8012 |
# File 'lib/syntax_tree/node.rb', line 8007 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
8005 8006 8007 |
# File 'lib/syntax_tree/node.rb', line 8005 def comments @comments end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to execute
7999 8000 8001 |
# File 'lib/syntax_tree/node.rb', line 7999 def statement @statement end |
#value ⇒ Object (readonly)
- untyped
-
the value to use if the executed expression raises an error
8002 8003 8004 |
# File 'lib/syntax_tree/node.rb', line 8002 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
8014 8015 8016 |
# File 'lib/syntax_tree/node.rb', line 8014 def accept(visitor) visitor.visit_rescue_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8018 8019 8020 |
# File 'lib/syntax_tree/node.rb', line 8018 def child_nodes [statement, value] end |
#deconstruct_keys(_keys) ⇒ Object
8024 8025 8026 8027 8028 8029 8030 8031 |
# File 'lib/syntax_tree/node.rb', line 8024 def deconstruct_keys(_keys) { statement: statement, value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 |
# File 'lib/syntax_tree/node.rb', line 8033 def format(q) q.text("begin") q.group do q.indent do q.breakable_force q.format(statement) end q.breakable_force q.text("rescue StandardError") q.indent do q.breakable_force q.format(value) end q.breakable_force end q.text("end") end |