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.



14869
14870
14871
14872
14873
14874
# File 'lib/prism/node.rb', line 14869

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



14920
14921
14922
# File 'lib/prism/node.rb', line 14920

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.



14926
14927
14928
# File 'lib/prism/node.rb', line 14926

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



14877
14878
14879
# File 'lib/prism/node.rb', line 14877

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

#child_nodesObject Also known as: deconstruct

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



14882
14883
14884
# File 'lib/prism/node.rb', line 14882

def child_nodes
  []
end

#comment_targetsObject

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



14892
14893
14894
# File 'lib/prism/node.rb', line 14892

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



14887
14888
14889
# File 'lib/prism/node.rb', line 14887

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



14897
14898
14899
# File 'lib/prism/node.rb', line 14897

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 }



14905
14906
14907
# File 'lib/prism/node.rb', line 14905

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

#inspectObject

def inspect -> String



14910
14911
14912
# File 'lib/prism/node.rb', line 14910

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



14915
14916
14917
# File 'lib/prism/node.rb', line 14915

def type
  :source_encoding_node
end