Class: Prism::NilNode

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

Overview

Represents the use of the ‘nil` keyword.

nil
^^^

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initialize a new NilNode node.



13486
13487
13488
13489
13490
13491
# File 'lib/prism/node.rb', line 13486

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`.



13537
13538
13539
# File 'lib/prism/node.rb', line 13537

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



13543
13544
13545
# File 'lib/prism/node.rb', line 13543

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



13494
13495
13496
# File 'lib/prism/node.rb', line 13494

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

#child_nodesObject Also known as: deconstruct

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



13499
13500
13501
# File 'lib/prism/node.rb', line 13499

def child_nodes
  []
end

#comment_targetsObject

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



13509
13510
13511
# File 'lib/prism/node.rb', line 13509

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



13504
13505
13506
# File 'lib/prism/node.rb', line 13504

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) -> NilNode



13514
13515
13516
# File 'lib/prism/node.rb', line 13514

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

#deconstruct_keys(keys) ⇒ Object

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



13522
13523
13524
# File 'lib/prism/node.rb', line 13522

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

#inspectObject

def inspect -> String



13527
13528
13529
# File 'lib/prism/node.rb', line 13527

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



13532
13533
13534
# File 'lib/prism/node.rb', line 13532

def type
  :nil_node
end