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.



14668
14669
14670
14671
14672
14673
14674
# File 'lib/prism/node.rb', line 14668

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



14716
14717
14718
# File 'lib/prism/node.rb', line 14716

def maximum
  @maximum
end

Class Method Details

.typeObject

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



14729
14730
14731
# File 'lib/prism/node.rb', line 14729

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.



14735
14736
14737
14738
# File 'lib/prism/node.rb', line 14735

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



14677
14678
14679
# File 'lib/prism/node.rb', line 14677

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



14682
14683
14684
# File 'lib/prism/node.rb', line 14682

def child_nodes
  []
end

#comment_targetsObject

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



14698
14699
14700
# File 'lib/prism/node.rb', line 14698

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



14693
14694
14695
# File 'lib/prism/node.rb', line 14693

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



14703
14704
14705
# File 'lib/prism/node.rb', line 14703

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 }



14711
14712
14713
# File 'lib/prism/node.rb', line 14711

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

#each_child_nodeObject

def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator



14687
14688
14689
14690
# File 'lib/prism/node.rb', line 14687

def each_child_node
  return to_enum(:each_child_node) unless block_given?

end

#inspectObject

def inspect -> String



14719
14720
14721
# File 'lib/prism/node.rb', line 14719

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



14724
14725
14726
# File 'lib/prism/node.rb', line 14724

def type
  :numbered_parameters_node
end