Class: Prism::NumberedParametersNode

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

Overview

Represents an implicit set of parameters through the use of numbered parameters within a block or lambda.

-> { _1 + _2 }
^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, maximum) ⇒ NumberedParametersNode

Initialize a new NumberedParametersNode node.



13663
13664
13665
13666
13667
13668
13669
# File 'lib/prism/node.rb', line 13663

def initialize(source, node_id, location, flags, maximum)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @maximum = maximum
end

Instance Attribute Details

#maximumObject (readonly)

attr_reader maximum: Integer



13705
13706
13707
# File 'lib/prism/node.rb', line 13705

def maximum
  @maximum
end

Class Method Details

.typeObject

Return a symbol representation of this node type. See ‘Node::type`.



13718
13719
13720
# File 'lib/prism/node.rb', line 13718

def self.type
  :numbered_parameters_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.



13724
13725
13726
13727
# File 'lib/prism/node.rb', line 13724

def ===(other)
  other.is_a?(NumberedParametersNode) &&
    (maximum === other.maximum)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



13672
13673
13674
# File 'lib/prism/node.rb', line 13672

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

#child_nodesObject Also known as: deconstruct

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



13677
13678
13679
# File 'lib/prism/node.rb', line 13677

def child_nodes
  []
end

#comment_targetsObject

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



13687
13688
13689
# File 'lib/prism/node.rb', line 13687

def comment_targets
  [] #: Array[Prism::node | Location]
end

#compact_child_nodesObject

def compact_child_nodes: () -> Array



13682
13683
13684
# File 'lib/prism/node.rb', line 13682

def compact_child_nodes
  []
end

#copy(node_id: self.node_id, location: self.location, flags: self.flags, maximum: self.maximum) ⇒ Object

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?maximum: Integer) -> NumberedParametersNode



13692
13693
13694
# File 'lib/prism/node.rb', line 13692

def copy(node_id: self.node_id, location: self.location, flags: self.flags, maximum: self.maximum)
  NumberedParametersNode.new(source, node_id, location, flags, maximum)
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, maximum: Integer }



13700
13701
13702
# File 'lib/prism/node.rb', line 13700

def deconstruct_keys(keys)
  { node_id: node_id, location: location, maximum: maximum }
end

#inspectObject

def inspect -> String



13708
13709
13710
# File 'lib/prism/node.rb', line 13708

def inspect
  InspectVisitor.compose(self)
end

#typeObject

Return a symbol representation of this node type. See ‘Node#type`.



13713
13714
13715
# File 'lib/prism/node.rb', line 13713

def type
  :numbered_parameters_node
end