Class: SyntaxTree::ArgParen
Overview
ArgParen represents wrapping arguments to a method inside a set of parentheses.
method(argument)
In the example above, there would be an ArgParen node around the Args node that represents the set of arguments being sent to the method method. The argument child node can be nil if no arguments were passed, as in:
method()
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
- nil | Args | ArgsForward
-
the arguments inside the parentheses.
-
#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: []) ⇒ ArgParen
constructor
A new instance of ArgParen.
Methods inherited from Node
Constructor Details
#initialize(arguments:, location:, comments: []) ⇒ ArgParen
Returns a new instance of ArgParen.
530 531 532 533 534 |
# File 'lib/syntax_tree/node.rb', line 530 def initialize(arguments:, location:, comments: []) @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- nil | Args | ArgsForward
-
the arguments inside the
parentheses
525 526 527 |
# File 'lib/syntax_tree/node.rb', line 525 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
528 529 530 |
# File 'lib/syntax_tree/node.rb', line 528 def comments @comments end |
Instance Method Details
#accept(visitor) ⇒ Object
536 537 538 |
# File 'lib/syntax_tree/node.rb', line 536 def accept(visitor) visitor.visit_arg_paren(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
540 541 542 |
# File 'lib/syntax_tree/node.rb', line 540 def child_nodes [arguments] end |
#deconstruct_keys(keys) ⇒ Object
546 547 548 |
# File 'lib/syntax_tree/node.rb', line 546 def deconstruct_keys(keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/syntax_tree/node.rb', line 550 def format(q) unless arguments q.text("()") return end q.group(0, "(", ")") do q.indent do q.breakable("") q.format(arguments) end q.breakable("") end end |