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, #format, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:) ⇒ WordsBeg

Returns a new instance of WordsBeg.



9844
9845
9846
9847
# File 'lib/syntax_tree/node.rb', line 9844

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

Instance Attribute Details

#valueObject (readonly)

String

the start of the word literal array



9842
9843
9844
# File 'lib/syntax_tree/node.rb', line 9842

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



9849
9850
9851
# File 'lib/syntax_tree/node.rb', line 9849

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

#child_nodesObject Also known as: deconstruct



9853
9854
9855
# File 'lib/syntax_tree/node.rb', line 9853

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



9859
9860
9861
# File 'lib/syntax_tree/node.rb', line 9859

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