Class: SyntaxTree::RescueEx
- Inherits:
-
Object
- Object
- SyntaxTree::RescueEx
- Defined in:
- lib/syntax_tree.rb
Overview
RescueEx represents the list of exceptions being rescued in a rescue clause.
begin
rescue Exception => exception
end
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#exceptions ⇒ Object
readonly
- untyped
-
the list of exceptions being rescued.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#variable ⇒ Object
readonly
- nil | Field | VarField
-
the expression being used to capture the raised exception.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(exceptions:, variable:, location:, comments: []) ⇒ RescueEx
constructor
A new instance of RescueEx.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(exceptions:, variable:, location:, comments: []) ⇒ RescueEx
Returns a new instance of RescueEx.
10106 10107 10108 10109 10110 10111 |
# File 'lib/syntax_tree.rb', line 10106 def initialize(exceptions:, variable:, location:, comments: []) @exceptions = exceptions @variable = variable @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10104 10105 10106 |
# File 'lib/syntax_tree.rb', line 10104 def comments @comments end |
#exceptions ⇒ Object (readonly)
- untyped
-
the list of exceptions being rescued
10094 10095 10096 |
# File 'lib/syntax_tree.rb', line 10094 def exceptions @exceptions end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
10101 10102 10103 |
# File 'lib/syntax_tree.rb', line 10101 def location @location end |
#variable ⇒ Object (readonly)
- nil | Field | VarField
-
the expression being used to capture the raised
exception
10098 10099 10100 |
# File 'lib/syntax_tree.rb', line 10098 def variable @variable end |
Instance Method Details
#child_nodes ⇒ Object
10113 10114 10115 |
# File 'lib/syntax_tree.rb', line 10113 def child_nodes [*exceptions, variable] end |
#format(q) ⇒ Object
10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 |
# File 'lib/syntax_tree.rb', line 10117 def format(q) q.group do if exceptions q.text(" ") q.format(exceptions) end if variable q.text(" => ") q.format(variable) end end end |
#pretty_print(q) ⇒ Object
10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 |
# File 'lib/syntax_tree.rb', line 10131 def pretty_print(q) q.group(2, "(", ")") do q.text("rescue_ex") q.breakable q.pp(exceptions) q.breakable q.pp(variable) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
10145 10146 10147 10148 10149 10150 10151 10152 10153 |
# File 'lib/syntax_tree.rb', line 10145 def to_json(*opts) { type: :rescue_ex, extns: exceptions, var: variable, loc: location, cmts: comments }.to_json(*opts) end |