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

Constructor Details

#initialize(value:, location:) ⇒ TStringEnd

Returns a new instance of TStringEnd.



10901
10902
10903
10904
# File 'lib/syntax_tree/node.rb', line 10901

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

Instance Attribute Details

#valueObject (readonly)

String

the end of the string



10899
10900
10901
# File 'lib/syntax_tree/node.rb', line 10899

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



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

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

#accept(visitor) ⇒ Object



10906
10907
10908
# File 'lib/syntax_tree/node.rb', line 10906

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

#child_nodesObject Also known as: deconstruct



10910
10911
10912
# File 'lib/syntax_tree/node.rb', line 10910

def child_nodes
  []
end

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



10914
10915
10916
10917
10918
10919
# File 'lib/syntax_tree/node.rb', line 10914

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

#deconstruct_keys(_keys) ⇒ Object



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

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