Class: Prism::RequiredParameterNode

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

Overview

Represents a required parameter to a method, block, or lambda definition.

def a(b)
      ^
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, name) ⇒ RequiredParameterNode

Initialize a new RequiredParameterNode node.



16672
16673
16674
16675
16676
16677
16678
# File 'lib/prism/node.rb', line 16672

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

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



16725
16726
16727
# File 'lib/prism/node.rb', line 16725

def name
  @name
end

Class Method Details

.typeObject

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



16738
16739
16740
# File 'lib/prism/node.rb', line 16738

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



16744
16745
16746
16747
16748
# File 'lib/prism/node.rb', line 16744

def ===(other)
  other.is_a?(RequiredParameterNode) &&
    (flags === other.flags) &&
    (name === other.name)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



16681
16682
16683
# File 'lib/prism/node.rb', line 16681

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



16686
16687
16688
# File 'lib/prism/node.rb', line 16686

def child_nodes
  []
end

#comment_targetsObject

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



16702
16703
16704
# File 'lib/prism/node.rb', line 16702

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



16697
16698
16699
# File 'lib/prism/node.rb', line 16697

def compact_child_nodes
  []
end

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

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> RequiredParameterNode



16707
16708
16709
# File 'lib/prism/node.rb', line 16707

def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name)
  RequiredParameterNode.new(source, node_id, location, flags, name)
end

#deconstruct_keys(keys) ⇒ Object

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



16715
16716
16717
# File 'lib/prism/node.rb', line 16715

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

#each_child_nodeObject

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



16691
16692
16693
16694
# File 'lib/prism/node.rb', line 16691

def each_child_node
  return to_enum(:each_child_node) unless block_given?

end

#inspectObject

def inspect -> String



16728
16729
16730
# File 'lib/prism/node.rb', line 16728

def inspect
  InspectVisitor.compose(self)
end

#repeated_parameter?Boolean

def repeated_parameter?: () -> bool

Returns:

  • (Boolean)


16720
16721
16722
# File 'lib/prism/node.rb', line 16720

def repeated_parameter?
  flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
end

#typeObject

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



16733
16734
16735
# File 'lib/prism/node.rb', line 16733

def type
  :required_parameter_node
end