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.



15707
15708
15709
15710
15711
15712
15713
# File 'lib/prism/node.rb', line 15707

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



15754
15755
15756
# File 'lib/prism/node.rb', line 15754

def name
  @name
end

Class Method Details

.typeObject

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



15767
15768
15769
# File 'lib/prism/node.rb', line 15767

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.



15773
15774
15775
15776
15777
# File 'lib/prism/node.rb', line 15773

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



15716
15717
15718
# File 'lib/prism/node.rb', line 15716

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



15721
15722
15723
# File 'lib/prism/node.rb', line 15721

def child_nodes
  []
end

#comment_targetsObject

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



15731
15732
15733
# File 'lib/prism/node.rb', line 15731

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



15726
15727
15728
# File 'lib/prism/node.rb', line 15726

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



15736
15737
15738
# File 'lib/prism/node.rb', line 15736

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 }



15744
15745
15746
# File 'lib/prism/node.rb', line 15744

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

#inspectObject

def inspect -> String



15757
15758
15759
# File 'lib/prism/node.rb', line 15757

def inspect
  InspectVisitor.compose(self)
end

#repeated_parameter?Boolean

def repeated_parameter?: () -> bool

Returns:

  • (Boolean)


15749
15750
15751
# File 'lib/prism/node.rb', line 15749

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

#typeObject

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



15762
15763
15764
# File 'lib/prism/node.rb', line 15762

def type
  :required_parameter_node
end