Class: Prism::SourceLineNode

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

Overview

Represents the use of the ‘__LINE__` keyword.

__LINE__
^^^^^^^^

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initialize a new SourceLineNode node.



15068
15069
15070
15071
15072
15073
# File 'lib/prism/node.rb', line 15068

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



15119
15120
15121
# File 'lib/prism/node.rb', line 15119

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



15125
15126
15127
# File 'lib/prism/node.rb', line 15125

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



15076
15077
15078
# File 'lib/prism/node.rb', line 15076

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

#child_nodesObject Also known as: deconstruct

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



15081
15082
15083
# File 'lib/prism/node.rb', line 15081

def child_nodes
  []
end

#comment_targetsObject

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



15091
15092
15093
# File 'lib/prism/node.rb', line 15091

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



15086
15087
15088
# File 'lib/prism/node.rb', line 15086

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



15096
15097
15098
# File 'lib/prism/node.rb', line 15096

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

#deconstruct_keys(keys) ⇒ Object

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



15104
15105
15106
# File 'lib/prism/node.rb', line 15104

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

#inspectObject

def inspect -> String



15109
15110
15111
# File 'lib/prism/node.rb', line 15109

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



15114
15115
15116
# File 'lib/prism/node.rb', line 15114

def type
  :source_line_node
end