class YARP::ParametersNode

Represents the list of parameters on a method, block, or lambda definition.

def a(b, c, d)
      ^^^^^^^
end

Attributes

block[R]

attr_reader block: BlockParameterNode?

keyword_rest[R]

attr_reader keyword_rest: Node?

keywords[R]

attr_reader keywords: Array

optionals[R]

attr_reader optionals: Array

posts[R]

attr_reader posts: Array

requireds[R]

attr_reader requireds: Array

rest[R]

attr_reader rest: RestParameterNode?

Public Class Methods

new(requireds, optionals, rest, posts, keywords, keyword_rest, block, location) click to toggle source

def initialize: (requireds: Array, optionals: Array, rest: RestParameterNode?, posts: Array, keywords: Array, keyword_rest: Node?, block: BlockParameterNode?, location: Location) -> void

# File yarp/node.rb, line 8124
def initialize(requireds, optionals, rest, posts, keywords, keyword_rest, block, location)
  @requireds = requireds
  @optionals = optionals
  @rest = rest
  @posts = posts
  @keywords = keywords
  @keyword_rest = keyword_rest
  @block = block
  @location = location
end

Public Instance Methods

accept(visitor) click to toggle source

def accept: (visitor: Visitor) -> void

# File yarp/node.rb, line 8136
def accept(visitor)
  visitor.visit_parameters_node(self)
end
child_nodes() click to toggle source

def child_nodes: () -> Array[nil | Node]

# File yarp/node.rb, line 8141
def child_nodes
  [*requireds, *optionals, rest, *posts, *keywords, keyword_rest, block]
end
Also aliased as: deconstruct
comment_targets() click to toggle source

def comment_targets: () -> Array[Node | Location]

# File yarp/node.rb, line 8146
def comment_targets
  [*requireds, *optionals, *rest, *posts, *keywords, *keyword_rest, *block]
end
copy(**params) click to toggle source

def copy: (**params) -> ParametersNode

# File yarp/node.rb, line 8151
def copy(**params)
  ParametersNode.new(
    params.fetch(:requireds) { requireds },
    params.fetch(:optionals) { optionals },
    params.fetch(:rest) { rest },
    params.fetch(:posts) { posts },
    params.fetch(:keywords) { keywords },
    params.fetch(:keyword_rest) { keyword_rest },
    params.fetch(:block) { block },
    params.fetch(:location) { location },
  )
end
deconstruct()

def deconstruct: () -> Array[nil | Node]

Alias for: child_nodes
deconstruct_keys(keys) click to toggle source

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]

# File yarp/node.rb, line 8168
def deconstruct_keys(keys)
  { requireds: requireds, optionals: optionals, rest: rest, posts: posts, keywords: keywords, keyword_rest: keyword_rest, block: block, location: location }
end
inspect(inspector = NodeInspector.new) click to toggle source
# File yarp/node.rb, line 8172
def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  inspector << "├── requireds: #{inspector.list("#{inspector.prefix}│   ", requireds)}"
  inspector << "├── optionals: #{inspector.list("#{inspector.prefix}│   ", optionals)}"
  if (rest = self.rest).nil?
    inspector << "├── rest: ∅\n"
  else
    inspector << "├── rest:\n"
    inspector << rest.inspect(inspector.child_inspector("│   ")).delete_prefix(inspector.prefix)
  end
  inspector << "├── posts: #{inspector.list("#{inspector.prefix}│   ", posts)}"
  inspector << "├── keywords: #{inspector.list("#{inspector.prefix}│   ", keywords)}"
  if (keyword_rest = self.keyword_rest).nil?
    inspector << "├── keyword_rest: ∅\n"
  else
    inspector << "├── keyword_rest:\n"
    inspector << keyword_rest.inspect(inspector.child_inspector("│   ")).delete_prefix(inspector.prefix)
  end
  if (block = self.block).nil?
    inspector << "└── block: ∅\n"
  else
    inspector << "└── block:\n"
    inspector << block.inspect(inspector.child_inspector("    ")).delete_prefix(inspector.prefix)
  end
  inspector.to_str
end