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.



8022
8023
8024
8025
8026
8027
8028
# File 'lib/prism/node.rb', line 8022

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.



8073
8074
8075
# File 'lib/prism/node.rb', line 8073

def block
  @block
end

Class Method Details

.typeObject

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



8086
8087
8088
# File 'lib/prism/node.rb', line 8086

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.



8092
8093
8094
8095
# File 'lib/prism/node.rb', line 8092

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



8031
8032
8033
# File 'lib/prism/node.rb', line 8031

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



8036
8037
8038
# File 'lib/prism/node.rb', line 8036

def child_nodes
  [block]
end

#comment_targetsObject

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



8055
8056
8057
# File 'lib/prism/node.rb', line 8055

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



8048
8049
8050
8051
8052
# File 'lib/prism/node.rb', line 8048

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



8060
8061
8062
# File 'lib/prism/node.rb', line 8060

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? }



8068
8069
8070
# File 'lib/prism/node.rb', line 8068

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

#each_child_node {|block| ... } ⇒ Object

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

Yields:



8041
8042
8043
8044
8045
# File 'lib/prism/node.rb', line 8041

def each_child_node
  return to_enum(:each_child_node) unless block_given?

  yield block if block
end

#inspectObject

def inspect -> String



8076
8077
8078
# File 'lib/prism/node.rb', line 8076

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



8081
8082
8083
# File 'lib/prism/node.rb', line 8081

def type
  :forwarding_super_node
end