Class: Prism::SourceEncodingNode

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

Overview

Represents the use of the ‘__ENCODING__` keyword.

__ENCODING__
^^^^^^^^^^^^

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initialize a new SourceEncodingNode node.



16644
16645
16646
16647
16648
16649
# File 'lib/prism/node.rb', line 16644

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



16695
16696
16697
# File 'lib/prism/node.rb', line 16695

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



16701
16702
16703
# File 'lib/prism/node.rb', line 16701

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



16652
16653
16654
# File 'lib/prism/node.rb', line 16652

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



16657
16658
16659
# File 'lib/prism/node.rb', line 16657

def child_nodes
  []
end

#comment_targetsObject

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



16667
16668
16669
# File 'lib/prism/node.rb', line 16667

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



16662
16663
16664
# File 'lib/prism/node.rb', line 16662

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



16672
16673
16674
# File 'lib/prism/node.rb', line 16672

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

#deconstruct_keys(keys) ⇒ Object

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



16680
16681
16682
# File 'lib/prism/node.rb', line 16680

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

#inspectObject

def inspect -> String



16685
16686
16687
# File 'lib/prism/node.rb', line 16685

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



16690
16691
16692
# File 'lib/prism/node.rb', line 16690

def type
  :source_encoding_node
end