class SyntaxTree::Args
Args
represents a list of arguments being passed to a method call or array literal.
method(first, second, third)
Attributes
parts[R]
- Array[
Node
] -
the arguments that this node wraps
Public Class Methods
new(parts:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 828 def initialize(parts:, location:) @parts = parts @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 863 def ===(other) other.is_a?(Args) && ArrayMatch.call(parts, other.parts) end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 834 def accept(visitor) visitor.visit_args(self) end
arity()
click to toggle source
# File lib/syntax_tree/node.rb, line 867 def arity parts.sum do |part| case part when ArgStar, ArgsForward Float::INFINITY when BareAssocHash part.assocs.sum do |assoc| assoc.is_a?(AssocSplat) ? Float::INFINITY : 1 end else 1 end end end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 838 def child_nodes parts end
Also aliased as: deconstruct
copy(parts: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 842 def copy(parts: nil, location: nil) node = Args.new( parts: parts || self.parts, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/node.rb, line 855 def deconstruct_keys(_keys) { parts: parts, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 859 def format(q) q.seplist(parts) { |part| q.format(part) } end