class SyntaxTree::Word
Word
represents an element within a special array literal that accepts interpolation.
%W[a#{b}c xyz]
In
the example above, there would be two Word
nodes within a parent Words
node.
Attributes
- Array[
StringEmbExpr
|StringDVar
|TStringContent
] -
the parts of the
word
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 12031 def initialize(parts:, location:) @parts = parts @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 12070 def ===(other) other.is_a?(Word) && ArrayMatch.call(parts, other.parts) end
Source
# File lib/syntax_tree/node.rb, line 12041 def accept(visitor) visitor.visit_word(self) end
Source
# File lib/syntax_tree/node.rb, line 12045 def child_nodes parts end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 12049 def copy(parts: nil, location: nil) node = Word.new( parts: parts || self.parts, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 12062 def deconstruct_keys(_keys) { parts: parts, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 12037 def match?(pattern) parts.any? { |part| part.is_a?(TStringContent) && part.match?(pattern) } end