Class: SyntaxTree::WordsBeg

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

Overview

WordsBeg represents the beginning of a string literal array with interpolation.

%W[one two three]

In the snippet above, a WordsBeg would be created with the value of “%W[”. 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:) ⇒ WordsBeg

Returns a new instance of WordsBeg.



12160
12161
12162
12163
# File 'lib/syntax_tree/node.rb', line 12160

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

Instance Attribute Details

#valueObject (readonly)

String

the start of the word literal array



12158
12159
12160
# File 'lib/syntax_tree/node.rb', line 12158

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



12186
12187
12188
# File 'lib/syntax_tree/node.rb', line 12186

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

#accept(visitor) ⇒ Object



12165
12166
12167
# File 'lib/syntax_tree/node.rb', line 12165

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

#child_nodesObject Also known as: deconstruct



12169
12170
12171
# File 'lib/syntax_tree/node.rb', line 12169

def child_nodes
  []
end

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



12173
12174
12175
12176
12177
12178
# File 'lib/syntax_tree/node.rb', line 12173

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

#deconstruct_keys(_keys) ⇒ Object



12182
12183
12184
# File 'lib/syntax_tree/node.rb', line 12182

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