Class: SyntaxTree::SymbolsBeg

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

Overview

SymbolsBeg represents the start of a symbol array literal with interpolation.

%I[one two three]

In the snippet above, SymbolsBeg 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, #end_char, #format, #pretty_print, #start_char, #to_json, #to_mermaid

Constructor Details

#initialize(value:, location:) ⇒ SymbolsBeg

Returns a new instance of SymbolsBeg.



10721
10722
10723
10724
# File 'lib/syntax_tree/node.rb', line 10721

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

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the symbol literal array



10719
10720
10721
# File 'lib/syntax_tree/node.rb', line 10719

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



10747
10748
10749
# File 'lib/syntax_tree/node.rb', line 10747

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

#accept(visitor) ⇒ Object



10726
10727
10728
# File 'lib/syntax_tree/node.rb', line 10726

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

#child_nodesObject Also known as: deconstruct



10730
10731
10732
# File 'lib/syntax_tree/node.rb', line 10730

def child_nodes
  []
end

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



10734
10735
10736
10737
10738
10739
# File 'lib/syntax_tree/node.rb', line 10734

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

#deconstruct_keys(_keys) ⇒ Object



10743
10744
10745
# File 'lib/syntax_tree/node.rb', line 10743

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