Class: Prism::SourceEncodingNode

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

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.

[View source]

16473
16474
16475
16476
16477
16478
# File 'lib/prism/node.rb', line 16473

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

[View source]

16524
16525
16526
# File 'lib/prism/node.rb', line 16524

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.

[View source]

16530
16531
16532
# File 'lib/prism/node.rb', line 16530

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void

[View source]

16481
16482
16483
# File 'lib/prism/node.rb', line 16481

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

#child_nodesObject Also known as: deconstruct

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

[View source]

16486
16487
16488
# File 'lib/prism/node.rb', line 16486

def child_nodes
  []
end

#comment_targetsObject

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

[View source]

16496
16497
16498
# File 'lib/prism/node.rb', line 16496

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array

[View source]

16491
16492
16493
# File 'lib/prism/node.rb', line 16491

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

[View source]

16501
16502
16503
# File 'lib/prism/node.rb', line 16501

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 }

[View source]

16509
16510
16511
# File 'lib/prism/node.rb', line 16509

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

#inspectObject

def inspect -> String

[View source]

16514
16515
16516
# File 'lib/prism/node.rb', line 16514

def inspect
  InspectVisitor.compose(self)
end

#typeObject

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

[View source]

16519
16520
16521
# File 'lib/prism/node.rb', line 16519

def type
  :source_encoding_node
end