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.



15536
15537
15538
15539
15540
15541
15542
# File 'lib/prism/node.rb', line 15536

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



15583
15584
15585
# File 'lib/prism/node.rb', line 15583

def name
  @name
end

Class Method Details

.typeObject

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



15596
15597
15598
# File 'lib/prism/node.rb', line 15596

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.



15602
15603
15604
15605
15606
# File 'lib/prism/node.rb', line 15602

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



15545
15546
15547
# File 'lib/prism/node.rb', line 15545

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

#child_nodesObject Also known as: deconstruct

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



15550
15551
15552
# File 'lib/prism/node.rb', line 15550

def child_nodes
  []
end

#comment_targetsObject

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



15560
15561
15562
# File 'lib/prism/node.rb', line 15560

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



15555
15556
15557
# File 'lib/prism/node.rb', line 15555

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



15565
15566
15567
# File 'lib/prism/node.rb', line 15565

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 }



15573
15574
15575
# File 'lib/prism/node.rb', line 15573

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

#inspectObject

def inspect -> String



15586
15587
15588
# File 'lib/prism/node.rb', line 15586

def inspect
  InspectVisitor.compose(self)
end

#repeated_parameter?Boolean

def repeated_parameter?: () -> bool

Returns:

  • (Boolean)


15578
15579
15580
# File 'lib/prism/node.rb', line 15578

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

#typeObject

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



15591
15592
15593
# File 'lib/prism/node.rb', line 15591

def type
  :required_parameter_node
end