Class: SyntaxTree::Super
Overview
Super represents using the super keyword with arguments. It can optionally use parentheses.
super(value)
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
- ArgParen | Args
-
the arguments to the keyword.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(arguments:, location:, comments: []) ⇒ Super
constructor
A new instance of Super.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(arguments:, location:, comments: []) ⇒ Super
Returns a new instance of Super.
8332 8333 8334 8335 8336 |
# File 'lib/syntax_tree/node.rb', line 8332 def initialize(arguments:, location:, comments: []) @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- ArgParen | Args
-
the arguments to the keyword
8327 8328 8329 |
# File 'lib/syntax_tree/node.rb', line 8327 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8330 8331 8332 |
# File 'lib/syntax_tree/node.rb', line 8330 def comments @comments end |
Instance Method Details
#accept(visitor) ⇒ Object
8338 8339 8340 |
# File 'lib/syntax_tree/node.rb', line 8338 def accept(visitor) visitor.visit_super(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8342 8343 8344 |
# File 'lib/syntax_tree/node.rb', line 8342 def child_nodes [arguments] end |
#deconstruct_keys(_keys) ⇒ Object
8348 8349 8350 |
# File 'lib/syntax_tree/node.rb', line 8348 def deconstruct_keys(_keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 |
# File 'lib/syntax_tree/node.rb', line 8352 def format(q) q.group do q.text("super") if arguments.is_a?(ArgParen) q.format(arguments) else q.text(" ") q.nest("super ".length) { q.format(arguments) } end end end |