Class: SyntaxTree::Super
- Inherits:
-
Object
- Object
- SyntaxTree::Super
- Defined in:
- lib/syntax_tree.rb
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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
Instance Method Summary collapse
- #child_nodes ⇒ 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.
11346 11347 11348 11349 11350 |
# File 'lib/syntax_tree.rb', line 11346 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
11338 11339 11340 |
# File 'lib/syntax_tree.rb', line 11338 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
11344 11345 11346 |
# File 'lib/syntax_tree.rb', line 11344 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
11341 11342 11343 |
# File 'lib/syntax_tree.rb', line 11341 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
11352 11353 11354 |
# File 'lib/syntax_tree.rb', line 11352 def child_nodes [arguments] end |
#format(q) ⇒ Object
11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 |
# File 'lib/syntax_tree.rb', line 11356 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
11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 |
# File 'lib/syntax_tree.rb', line 11369 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
11380 11381 11382 11383 11384 |
# File 'lib/syntax_tree.rb', line 11380 def to_json(*opts) { type: :super, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |