Class: SyntaxTree::TStringEnd

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

Overview

TStringEnd represents the end of a string literal.

"string"

In the example above, TStringEnd represents the second 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:) ⇒ TStringEnd

Returns a new instance of TStringEnd.



10994
10995
10996
10997
# File 'lib/syntax_tree/node.rb', line 10994

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

Instance Attribute Details

#valueObject (readonly)

String

the end of the string



10992
10993
10994
# File 'lib/syntax_tree/node.rb', line 10992

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



11020
11021
11022
# File 'lib/syntax_tree/node.rb', line 11020

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

#accept(visitor) ⇒ Object



10999
11000
11001
# File 'lib/syntax_tree/node.rb', line 10999

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

#child_nodesObject Also known as: deconstruct



11003
11004
11005
# File 'lib/syntax_tree/node.rb', line 11003

def child_nodes
  []
end

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



11007
11008
11009
11010
11011
11012
# File 'lib/syntax_tree/node.rb', line 11007

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

#deconstruct_keys(_keys) ⇒ Object



11016
11017
11018
# File 'lib/syntax_tree/node.rb', line 11016

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