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

#construct_keys, #pretty_print, #to_json

Constructor Details

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

Returns a new instance of XStringLiteral.



10027
10028
10029
10030
10031
# File 'lib/syntax_tree/node.rb', line 10027

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



10025
10026
10027
# File 'lib/syntax_tree/node.rb', line 10025

def comments
  @comments
end

#partsObject (readonly)

Array[ StringEmbExpr | StringDVar | TStringContent ]

the parts of the

xstring



10022
10023
10024
# File 'lib/syntax_tree/node.rb', line 10022

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



10033
10034
10035
# File 'lib/syntax_tree/node.rb', line 10033

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

#child_nodesObject Also known as: deconstruct



10037
10038
10039
# File 'lib/syntax_tree/node.rb', line 10037

def child_nodes
  parts
end

#deconstruct_keys(_keys) ⇒ Object



10043
10044
10045
# File 'lib/syntax_tree/node.rb', line 10043

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

#format(q) ⇒ Object



10047
10048
10049
10050
10051
# File 'lib/syntax_tree/node.rb', line 10047

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