class SyntaxTree::TStringContent

TStringContent represents plain characters inside of an entity that accepts string content like a string, heredoc, command string, or regular expression.

"string"

In the example above, TStringContent represents the string token contained within the string.

Attributes

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

value[R]
String

the content of the string

Public Class Methods

new(value:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 10984
def initialize(value:, location:)
  @value = value
  @location = location
  @comments = []
end

Public Instance Methods

===(other) click to toggle source
# File lib/syntax_tree/node.rb, line 11023
def ===(other)
  other.is_a?(TStringContent) && value === other.value
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 10994
def accept(visitor)
  visitor.visit_tstring_content(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 10998
def child_nodes
  []
end
Also aliased as: deconstruct
copy(value: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 11002
def copy(value: nil, location: nil)
  node =
    TStringContent.new(
      value: value || self.value,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end
deconstruct()
Alias for: child_nodes
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/node.rb, line 11015
def deconstruct_keys(_keys)
  { value: value, location: location, comments: comments }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 11019
def format(q)
  q.text(value)
end
match?(pattern) click to toggle source
# File lib/syntax_tree/node.rb, line 10990
def match?(pattern)
  value.match?(pattern)
end