Class: Prism::ForwardingSuperNode

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

Overview

Represents the use of the ‘super` keyword without parentheses or arguments, but which might have a block.

super
^^^^^

super { 123 }
^^^^^^^^^^^^^

If it has any other arguments, it would be a ‘SuperNode` instead.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, block) ⇒ ForwardingSuperNode

Initialize a new ForwardingSuperNode node.



7582
7583
7584
7585
7586
7587
7588
# File 'lib/prism/node.rb', line 7582

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

Instance Attribute Details

#blockObject (readonly)

All other arguments are forwarded as normal, except the original block is replaced with the new block.



7626
7627
7628
# File 'lib/prism/node.rb', line 7626

def block
  @block
end

Class Method Details

.typeObject

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



7639
7640
7641
# File 'lib/prism/node.rb', line 7639

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



7645
7646
7647
7648
# File 'lib/prism/node.rb', line 7645

def ===(other)
  other.is_a?(ForwardingSuperNode) &&
    (block === other.block)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



7591
7592
7593
# File 'lib/prism/node.rb', line 7591

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



7596
7597
7598
# File 'lib/prism/node.rb', line 7596

def child_nodes
  [block]
end

#comment_targetsObject

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



7608
7609
7610
# File 'lib/prism/node.rb', line 7608

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



7601
7602
7603
7604
7605
# File 'lib/prism/node.rb', line 7601

def compact_child_nodes
  compact = [] #: Array[Prism::node]
  compact << block if block
  compact
end

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

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?block: BlockNode?) -> ForwardingSuperNode



7613
7614
7615
# File 'lib/prism/node.rb', line 7613

def copy(node_id: self.node_id, location: self.location, flags: self.flags, block: self.block)
  ForwardingSuperNode.new(source, node_id, location, flags, block)
end

#deconstruct_keys(keys) ⇒ Object

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



7621
7622
7623
# File 'lib/prism/node.rb', line 7621

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

#inspectObject

def inspect -> String



7629
7630
7631
# File 'lib/prism/node.rb', line 7629

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



7634
7635
7636
# File 'lib/prism/node.rb', line 7634

def type
  :forwarding_super_node
end