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.



11966
11967
11968
11969
# File 'lib/syntax_tree/node.rb', line 11966

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

Instance Attribute Details

#valueObject (readonly)

String

the start of the word literal array



11964
11965
11966
# File 'lib/syntax_tree/node.rb', line 11964

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



11992
11993
11994
# File 'lib/syntax_tree/node.rb', line 11992

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

#accept(visitor) ⇒ Object



11971
11972
11973
# File 'lib/syntax_tree/node.rb', line 11971

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

#child_nodesObject Also known as: deconstruct



11975
11976
11977
# File 'lib/syntax_tree/node.rb', line 11975

def child_nodes
  []
end

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



11979
11980
11981
11982
11983
11984
# File 'lib/syntax_tree/node.rb', line 11979

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

#deconstruct_keys(_keys) ⇒ Object



11988
11989
11990
# File 'lib/syntax_tree/node.rb', line 11988

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