Class: SyntaxTree::TStringBeg

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

Overview

TStringBeg represents the beginning of a string literal.

"string"

In the example above, TStringBeg represents the first set of quotes. Strings can also use single quotes. They can also be declared using the %q and %Q syntax, as in:

%q{string}

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

Returns a new instance of TStringBeg.



10921
10922
10923
10924
# File 'lib/syntax_tree/node.rb', line 10921

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

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the string



10919
10920
10921
# File 'lib/syntax_tree/node.rb', line 10919

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



10947
10948
10949
# File 'lib/syntax_tree/node.rb', line 10947

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

#accept(visitor) ⇒ Object



10926
10927
10928
# File 'lib/syntax_tree/node.rb', line 10926

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

#child_nodesObject Also known as: deconstruct



10930
10931
10932
# File 'lib/syntax_tree/node.rb', line 10930

def child_nodes
  []
end

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



10934
10935
10936
10937
10938
10939
# File 'lib/syntax_tree/node.rb', line 10934

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

#deconstruct_keys(_keys) ⇒ Object



10943
10944
10945
# File 'lib/syntax_tree/node.rb', line 10943

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