Class: SyntaxTree::QSymbolsBeg

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

QSymbolsBeg represents the beginning of a symbol literal array.

i[one two three]

In the snippet above, QSymbolsBeg represents the “%i[” token. Note that these kinds of arrays can start with a lot of different delimiter types (e.g., %i| or %i<).

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #format, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:) ⇒ QSymbolsBeg

Returns a new instance of QSymbolsBeg.



8605
8606
8607
8608
# File 'lib/syntax_tree/node.rb', line 8605

def initialize(value:, location:)
  @value = value
  @location = location
end

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the array literal



8603
8604
8605
# File 'lib/syntax_tree/node.rb', line 8603

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



8631
8632
8633
# File 'lib/syntax_tree/node.rb', line 8631

def ===(other)
  other.is_a?(QSymbolsBeg) && value === other.value
end

#accept(visitor) ⇒ Object



8610
8611
8612
# File 'lib/syntax_tree/node.rb', line 8610

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

#child_nodesObject Also known as: deconstruct



8614
8615
8616
# File 'lib/syntax_tree/node.rb', line 8614

def child_nodes
  []
end

#copy(value: nil, location: nil) ⇒ Object



8618
8619
8620
8621
8622
8623
# File 'lib/syntax_tree/node.rb', line 8618

def copy(value: nil, location: nil)
  QSymbolsBeg.new(
    value: value || self.value,
    location: location || self.location
  )
end

#deconstruct_keys(_keys) ⇒ Object



8627
8628
8629
# File 'lib/syntax_tree/node.rb', line 8627

def deconstruct_keys(_keys)
  { value: value, location: location }
end