Class: SyntaxTree::QWordsBeg

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

Overview

QWordsBeg represents the beginning of a string literal array.

%w[one two three]

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

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:) ⇒ QWordsBeg

Returns a new instance of QWordsBeg.



8862
8863
8864
8865
# File 'lib/syntax_tree/node.rb', line 8862

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

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the array literal



8860
8861
8862
# File 'lib/syntax_tree/node.rb', line 8860

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



8888
8889
8890
# File 'lib/syntax_tree/node.rb', line 8888

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

#accept(visitor) ⇒ Object



8867
8868
8869
# File 'lib/syntax_tree/node.rb', line 8867

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

#child_nodesObject Also known as: deconstruct



8871
8872
8873
# File 'lib/syntax_tree/node.rb', line 8871

def child_nodes
  []
end

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



8875
8876
8877
8878
8879
8880
# File 'lib/syntax_tree/node.rb', line 8875

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

#deconstruct_keys(_keys) ⇒ Object



8884
8885
8886
# File 'lib/syntax_tree/node.rb', line 8884

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