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
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(arguments:, location:, comments: []) ⇒ Super
constructor
A new instance of Super.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(arguments:, location:, comments: []) ⇒ Super
Returns a new instance of Super.
9480 9481 9482 9483 9484 |
# File 'lib/syntax_tree/node.rb', line 9480 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
9475 9476 9477 |
# File 'lib/syntax_tree/node.rb', line 9475 def arguments @arguments end |
#comments ⇒ Object (readonly)
[Array[ Comment | EmbDoc ]] the comments attached to this node
9478 9479 9480 |
# File 'lib/syntax_tree/node.rb', line 9478 def comments @comments end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
9486 9487 9488 |
# File 'lib/syntax_tree/node.rb', line 9486 def child_nodes [arguments] end |
#deconstruct_keys(keys) ⇒ Object
9492 9493 9494 |
# File 'lib/syntax_tree/node.rb', line 9492 def deconstruct_keys(keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 |
# File 'lib/syntax_tree/node.rb', line 9496 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 |
#pretty_print(q) ⇒ Object
9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 |
# File 'lib/syntax_tree/node.rb', line 9509 def pretty_print(q) q.group(2, "(", ")") do q.text("super") q.breakable q.pp(arguments) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
9520 9521 9522 9523 9524 |
# File 'lib/syntax_tree/node.rb', line 9520 def to_json(*opts) { type: :super, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |