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.



11058
11059
11060
11061
# File 'lib/syntax_tree/node.rb', line 11058

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

Instance Attribute Details

#valueObject (readonly)

String

the end of the string



11056
11057
11058
# File 'lib/syntax_tree/node.rb', line 11056

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



11084
11085
11086
# File 'lib/syntax_tree/node.rb', line 11084

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

#accept(visitor) ⇒ Object



11063
11064
11065
# File 'lib/syntax_tree/node.rb', line 11063

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

#child_nodesObject Also known as: deconstruct



11067
11068
11069
# File 'lib/syntax_tree/node.rb', line 11067

def child_nodes
  []
end

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



11071
11072
11073
11074
11075
11076
# File 'lib/syntax_tree/node.rb', line 11071

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

#deconstruct_keys(_keys) ⇒ Object



11080
11081
11082
# File 'lib/syntax_tree/node.rb', line 11080

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