class SyntaxTree::ArgParen
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()
Attributes
- nil |
Args
|ArgsForward
-
the arguments inside the
parentheses
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 735 def initialize(arguments:, location:) @arguments = arguments @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 784 def ===(other) other.is_a?(ArgParen) && arguments === other.arguments end
Source
# File lib/syntax_tree/node.rb, line 741 def accept(visitor) visitor.visit_arg_paren(self) end
Source
# File lib/syntax_tree/node.rb, line 745 def child_nodes [arguments] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 749 def copy(arguments: nil, location: nil) node = ArgParen.new( arguments: arguments || self.arguments, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 762 def deconstruct_keys(_keys) { arguments: arguments, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 766 def format(q) unless arguments q.text("()") return end q.text("(") q.group do q.indent do q.breakable_empty q.format(arguments) q.if_break { q.text(",") } if q.trailing_comma? && trailing_comma? end q.breakable_empty end q.text(")") end