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.



10066
10067
10068
10069
10070
# File 'lib/syntax_tree/node.rb', line 10066

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



10064
10065
10066
# File 'lib/syntax_tree/node.rb', line 10064

def comments
  @comments
end

#partsObject (readonly)

Array[ StringEmbExpr | StringDVar | TStringContent ]

the parts of the

xstring



10061
10062
10063
# File 'lib/syntax_tree/node.rb', line 10061

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



10072
10073
10074
# File 'lib/syntax_tree/node.rb', line 10072

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

#child_nodesObject Also known as: deconstruct



10076
10077
10078
# File 'lib/syntax_tree/node.rb', line 10076

def child_nodes
  parts
end

#deconstruct_keys(_keys) ⇒ Object



10082
10083
10084
# File 'lib/syntax_tree/node.rb', line 10082

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

#format(q) ⇒ Object



10086
10087
10088
10089
10090
# File 'lib/syntax_tree/node.rb', line 10086

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