class SyntaxTree::StringEmbExpr
StringEmbExpr
represents interpolated content. It can be contained within a couple of different parent nodes, including regular expressions, strings, and dynamic symbols.
"string #{expression}"
Attributes
Statements
-
the expressions to be interpolated
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 10267 def initialize(statements:, location:) @statements = statements @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 10324 def ===(other) other.is_a?(StringEmbExpr) && statements === other.statements end
Source
# File lib/syntax_tree/node.rb, line 10273 def accept(visitor) visitor.visit_string_embexpr(self) end
Source
# File lib/syntax_tree/node.rb, line 10277 def child_nodes [statements] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 10281 def copy(statements: nil, location: nil) node = StringEmbExpr.new( statements: statements || self.statements, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 10294 def deconstruct_keys(_keys) { statements: statements, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 10298 def format(q) if location.start_line == location.end_line # If the contents of this embedded expression were originally on the # same line in the source, then we're going to leave them in place and # assume that's the way the developer wanted this expression # represented. q.remove_breaks( q.group do q.text('#{') q.format(statements) q.text("}") end ) else q.group do q.text('#{') q.indent do q.breakable_empty q.format(statements) end q.breakable_empty q.text("}") end end end