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.
8412 8413 8414 8415 8416 |
# File 'lib/syntax_tree/node.rb', line 8412 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
8407 8408 8409 |
# File 'lib/syntax_tree/node.rb', line 8407 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8410 8411 8412 |
# File 'lib/syntax_tree/node.rb', line 8410 def comments @comments end |
Instance Method Details
#accept(visitor) ⇒ Object
8418 8419 8420 |
# File 'lib/syntax_tree/node.rb', line 8418 def accept(visitor) visitor.visit_super(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8422 8423 8424 |
# File 'lib/syntax_tree/node.rb', line 8422 def child_nodes [arguments] end |
#deconstruct_keys(_keys) ⇒ Object
8428 8429 8430 |
# File 'lib/syntax_tree/node.rb', line 8428 def deconstruct_keys(_keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 |
# File 'lib/syntax_tree/node.rb', line 8432 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 |