Class: SyntaxTree::XStringLiteral

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

Overview

XStringLiteral represents a string that gets executed.

`ls`

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#pretty_print, #to_json

Constructor Details

#initialize(parts:, location:, comments: []) ⇒ XStringLiteral

Returns a new instance of XStringLiteral.



9793
9794
9795
9796
9797
# File 'lib/syntax_tree/node.rb', line 9793

def initialize(parts:, location:, comments: [])
  @parts = parts
  @location = location
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



9791
9792
9793
# File 'lib/syntax_tree/node.rb', line 9791

def comments
  @comments
end

#partsObject (readonly)

Array[ StringEmbExpr | StringDVar | TStringContent ]

the parts of the

xstring



9788
9789
9790
# File 'lib/syntax_tree/node.rb', line 9788

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



9799
9800
9801
# File 'lib/syntax_tree/node.rb', line 9799

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

#child_nodesObject Also known as: deconstruct



9803
9804
9805
# File 'lib/syntax_tree/node.rb', line 9803

def child_nodes
  parts
end

#deconstruct_keys(keys) ⇒ Object



9809
9810
9811
# File 'lib/syntax_tree/node.rb', line 9809

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

#format(q) ⇒ Object



9813
9814
9815
9816
9817
# File 'lib/syntax_tree/node.rb', line 9813

def format(q)
  q.text("`")
  q.format_each(parts)
  q.text("`")
end