Class: SyntaxTree::StringContent

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

Overview

StringContent represents the contents of a string-like value.

"string"

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print, #to_json

Constructor Details

#initialize(parts:, location:) ⇒ StringContent

Returns a new instance of StringContent.



7984
7985
7986
7987
# File 'lib/syntax_tree/node.rb', line 7984

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

Instance Attribute Details

#parts ⇒ Object (readonly)

[Array[ StringEmbExpr | StringDVar | TStringContent ]] the parts of the string



7982
7983
7984
# File 'lib/syntax_tree/node.rb', line 7982

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



7989
7990
7991
# File 'lib/syntax_tree/node.rb', line 7989

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

#child_nodes ⇒ Object Also known as: deconstruct



7993
7994
7995
# File 'lib/syntax_tree/node.rb', line 7993

def child_nodes
  parts
end

#deconstruct_keys(keys) ⇒ Object



7999
8000
8001
# File 'lib/syntax_tree/node.rb', line 7999

def deconstruct_keys(keys)
  { parts: parts, location: location }
end