class SyntaxTree::StringDVar
StringDVar
represents shorthand interpolation of a variable into a string. It allows you to take an instance variable, class variable, or global variable and omit the braces when interpolating.
"#@variable"
Attributes
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 10212 def initialize(variable:, location:) @variable = variable @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 10249 def ===(other) other.is_a?(StringDVar) && variable === other.variable end
Source
# File lib/syntax_tree/node.rb, line 10218 def accept(visitor) visitor.visit_string_dvar(self) end
Source
# File lib/syntax_tree/node.rb, line 10222 def child_nodes [variable] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 10226 def copy(variable: nil, location: nil) node = StringDVar.new( variable: variable || self.variable, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 10239 def deconstruct_keys(_keys) { variable: variable, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 10243 def format(q) q.text('#{') q.format(variable) q.text("}") end