class SyntaxTree::RestParam

RestParam represents defining a parameter in a method definition that accepts all remaining positional parameters.

def method(*rest) end

Attributes

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

name[R]
nil | Ident

the name of the parameter

Public Class Methods

new(name:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 9615
def initialize(name:, location:)
  @name = name
  @location = location
  @comments = []
end

Public Instance Methods

===(other) click to toggle source
# File lib/syntax_tree/node.rb, line 9651
def ===(other)
  other.is_a?(RestParam) && name === other.name
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 9621
def accept(visitor)
  visitor.visit_rest_param(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 9625
def child_nodes
  [name]
end
Also aliased as: deconstruct
copy(name: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 9629
def copy(name: nil, location: nil)
  node =
    RestParam.new(
      name: name || self.name,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end
deconstruct()
Alias for: child_nodes
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/node.rb, line 9642
def deconstruct_keys(_keys)
  { name: name, location: location, comments: comments }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 9646
def format(q)
  q.text("*")
  q.format(name) if name
end