Class: YARP::ArgumentsNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents a set of arguments to a method or a keyword.

return foo, bar, baz
       ^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments, location) ⇒ ArgumentsNode

def initialize: (arguments: Array, location: Location) -> void



231
232
233
234
# File 'lib/yarp/node.rb', line 231

def initialize(arguments, location)
  @arguments = arguments
  @location = location
end

Instance Attribute Details

#argumentsObject (readonly)

attr_reader arguments: Array



228
229
230
# File 'lib/yarp/node.rb', line 228

def arguments
  @arguments
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



237
238
239
# File 'lib/yarp/node.rb', line 237

def accept(visitor)
  visitor.visit_arguments_node(self)
end

#child_nodesObject Also known as: deconstruct

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



242
243
244
# File 'lib/yarp/node.rb', line 242

def child_nodes
  [*arguments]
end

#comment_targetsObject

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



247
248
249
# File 'lib/yarp/node.rb', line 247

def comment_targets
  [*arguments]
end

#copy(**params) ⇒ Object

def copy: (**params) -> ArgumentsNode



252
253
254
255
256
257
# File 'lib/yarp/node.rb', line 252

def copy(**params)
  ArgumentsNode.new(
    params.fetch(:arguments) { arguments },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

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



263
264
265
# File 'lib/yarp/node.rb', line 263

def deconstruct_keys(keys)
  { arguments: arguments, location: location }
end

#inspect(inspector = NodeInspector.new) ⇒ Object



267
268
269
270
271
# File 'lib/yarp/node.rb', line 267

def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  inspector << "└── arguments: #{inspector.list("#{inspector.prefix}    ", arguments)}"
  inspector.to_str
end