Class: YARP::ForwardingSuperNode

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

Overview

Represents the use of the ‘super` keyword without parentheses or arguments.

super
^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, location) ⇒ ForwardingSuperNode

def initialize: (block: BlockNode?, location: Location) -> void



4457
4458
4459
4460
# File 'lib/yarp/node.rb', line 4457

def initialize(block, location)
  @block = block
  @location = location
end

Instance Attribute Details

#blockObject (readonly)

attr_reader block: BlockNode?



4454
4455
4456
# File 'lib/yarp/node.rb', line 4454

def block
  @block
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4463
4464
4465
# File 'lib/yarp/node.rb', line 4463

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

#child_nodesObject Also known as: deconstruct

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



4468
4469
4470
# File 'lib/yarp/node.rb', line 4468

def child_nodes
  [block]
end

#comment_targetsObject

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



4473
4474
4475
# File 'lib/yarp/node.rb', line 4473

def comment_targets
  [*block]
end

#copy(**params) ⇒ Object

def copy: (**params) -> ForwardingSuperNode



4478
4479
4480
4481
4482
4483
# File 'lib/yarp/node.rb', line 4478

def copy(**params)
  ForwardingSuperNode.new(
    params.fetch(:block) { block },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



4489
4490
4491
# File 'lib/yarp/node.rb', line 4489

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

#inspect(inspector = NodeInspector.new) ⇒ Object



4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
# File 'lib/yarp/node.rb', line 4493

def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  if (block = self.block).nil?
    inspector << "└── block: ∅\n"
  else
    inspector << "└── block:\n"
    inspector << block.inspect(inspector.child_inspector("    ")).delete_prefix(inspector.prefix)
  end
  inspector.to_str
end