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.



12106
12107
12108
12109
12110
12111
# File 'lib/prism/node.rb', line 12106

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



12157
12158
12159
# File 'lib/prism/node.rb', line 12157

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.



12163
12164
12165
# File 'lib/prism/node.rb', line 12163

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



12114
12115
12116
# File 'lib/prism/node.rb', line 12114

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

#child_nodesObject Also known as: deconstruct

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



12119
12120
12121
# File 'lib/prism/node.rb', line 12119

def child_nodes
  []
end

#comment_targetsObject

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



12129
12130
12131
# File 'lib/prism/node.rb', line 12129

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



12124
12125
12126
# File 'lib/prism/node.rb', line 12124

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



12134
12135
12136
# File 'lib/prism/node.rb', line 12134

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 }



12142
12143
12144
# File 'lib/prism/node.rb', line 12142

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

#inspectObject

def inspect -> String



12147
12148
12149
# File 'lib/prism/node.rb', line 12147

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



12152
12153
12154
# File 'lib/prism/node.rb', line 12152

def type
  :nil_node
end