Class: Prism::RestParameterNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::RestParameterNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents a rest parameter to a method, block, or lambda definition.
def a(*b)
^^
end
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol?.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> RestParameterNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol?, name_loc: Location?, operator_loc: Location }.
-
#initialize(source, node_id, location, flags, name, name_loc, operator_loc) ⇒ RestParameterNode
constructor
Initialize a new RestParameterNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#name_loc ⇒ Object
attr_reader name_loc: Location?.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
attr_reader operator_loc: Location.
-
#repeated_parameter? ⇒ Boolean
def repeated_parameter?: () -> bool.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, name, name_loc, operator_loc) ⇒ RestParameterNode
Initialize a new RestParameterNode node.
14354 14355 14356 14357 14358 14359 14360 14361 14362 |
# File 'lib/prism/node.rb', line 14354 def initialize(source, node_id, location, flags, name, name_loc, operator_loc) @source = source @node_id = node_id @location = location @flags = flags @name = name @name_loc = name_loc @operator_loc = operator_loc end |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol?
14403 14404 14405 |
# File 'lib/prism/node.rb', line 14403 def name @name end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
14441 14442 14443 |
# File 'lib/prism/node.rb', line 14441 def self.type :rest_parameter_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
14447 14448 14449 14450 14451 14452 14453 |
# File 'lib/prism/node.rb', line 14447 def ===(other) other.is_a?(RestParameterNode) && (flags === other.flags) && (name === other.name) && (name_loc.nil? == other.name_loc.nil?) && (operator_loc.nil? == other.operator_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
14365 14366 14367 |
# File 'lib/prism/node.rb', line 14365 def accept(visitor) visitor.visit_rest_parameter_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
14370 14371 14372 |
# File 'lib/prism/node.rb', line 14370 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
14380 14381 14382 |
# File 'lib/prism/node.rb', line 14380 def comment_targets [*name_loc, operator_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
14375 14376 14377 |
# File 'lib/prism/node.rb', line 14375 def compact_child_nodes [] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> RestParameterNode
14385 14386 14387 |
# File 'lib/prism/node.rb', line 14385 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) RestParameterNode.new(source, node_id, location, flags, name, name_loc, operator_loc) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol?, name_loc: Location?, operator_loc: Location }
14393 14394 14395 |
# File 'lib/prism/node.rb', line 14393 def deconstruct_keys(keys) { node_id: node_id, location: location, name: name, name_loc: name_loc, operator_loc: operator_loc } end |
#inspect ⇒ Object
def inspect -> String
14431 14432 14433 |
# File 'lib/prism/node.rb', line 14431 def inspect InspectVisitor.compose(self) end |
#name_loc ⇒ Object
attr_reader name_loc: Location?
14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 |
# File 'lib/prism/node.rb', line 14406 def name_loc location = @name_loc case location when nil nil when Location location else @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end |
#operator ⇒ Object
def operator: () -> String
14426 14427 14428 |
# File 'lib/prism/node.rb', line 14426 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
14419 14420 14421 14422 14423 |
# File 'lib/prism/node.rb', line 14419 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#repeated_parameter? ⇒ Boolean
def repeated_parameter?: () -> bool
14398 14399 14400 |
# File 'lib/prism/node.rb', line 14398 def repeated_parameter? flags.anybits?(ParameterFlags::REPEATED_PARAMETER) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
14436 14437 14438 |
# File 'lib/prism/node.rb', line 14436 def type :rest_parameter_node end |