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

#construct_keys, #format, #pretty_print, #to_json

Constructor Details

#initialize(parts:, location:) ⇒ StringContent

Returns a new instance of StringContent.



8212
8213
8214
8215
# File 'lib/syntax_tree/node.rb', line 8212

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

Instance Attribute Details

#partsObject (readonly)

Array[ StringEmbExpr | StringDVar | TStringContent ]

the parts of the

string



8210
8211
8212
# File 'lib/syntax_tree/node.rb', line 8210

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



8217
8218
8219
# File 'lib/syntax_tree/node.rb', line 8217

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

#child_nodesObject Also known as: deconstruct



8221
8222
8223
# File 'lib/syntax_tree/node.rb', line 8221

def child_nodes
  parts
end

#deconstruct_keys(_keys) ⇒ Object



8227
8228
8229
# File 'lib/syntax_tree/node.rb', line 8227

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