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.



14906
14907
14908
14909
14910
14911
# File 'lib/prism/node.rb', line 14906

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



14957
14958
14959
# File 'lib/prism/node.rb', line 14957

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.



14963
14964
14965
# File 'lib/prism/node.rb', line 14963

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



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

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

#child_nodesObject Also known as: deconstruct

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



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

def child_nodes
  []
end

#comment_targetsObject

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



14929
14930
14931
# File 'lib/prism/node.rb', line 14929

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



14924
14925
14926
# File 'lib/prism/node.rb', line 14924

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



14934
14935
14936
# File 'lib/prism/node.rb', line 14934

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 }



14942
14943
14944
# File 'lib/prism/node.rb', line 14942

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

#inspectObject

def inspect -> String



14947
14948
14949
# File 'lib/prism/node.rb', line 14947

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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



14952
14953
14954
# File 'lib/prism/node.rb', line 14952

def type
  :source_encoding_node
end