Class: Prism::SelfNode

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

Overview

Represents the ‘self` keyword.

self
^^^^

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags) ⇒ SelfNode

Initialize a new SelfNode node.



16376
16377
16378
16379
16380
16381
# File 'lib/prism/node.rb', line 16376

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

Class Method Details

.typeObject

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



16427
16428
16429
# File 'lib/prism/node.rb', line 16427

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



16433
16434
16435
# File 'lib/prism/node.rb', line 16433

def ===(other)
  other.is_a?(SelfNode)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



16384
16385
16386
# File 'lib/prism/node.rb', line 16384

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



16389
16390
16391
# File 'lib/prism/node.rb', line 16389

def child_nodes
  []
end

#comment_targetsObject

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



16399
16400
16401
# File 'lib/prism/node.rb', line 16399

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



16394
16395
16396
# File 'lib/prism/node.rb', line 16394

def compact_child_nodes
  []
end

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

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> SelfNode



16404
16405
16406
# File 'lib/prism/node.rb', line 16404

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

#deconstruct_keys(keys) ⇒ Object

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



16412
16413
16414
# File 'lib/prism/node.rb', line 16412

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

#inspectObject

def inspect -> String



16417
16418
16419
# File 'lib/prism/node.rb', line 16417

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



16422
16423
16424
# File 'lib/prism/node.rb', line 16422

def type
  :self_node
end