class SyntaxTree::Words
%W[one two three]
Words represents a string literal array with interpolation.
def ===(other)
def ===(other) other.is_a?(Words) && beginning === other.beginning && ArrayMatch.call(elements, other.elements) end
def accept(visitor)
def accept(visitor) visitor.visit_words(self) end
def child_nodes
def child_nodes [] end
def copy(beginning: nil, elements: nil, location: nil)
def copy(beginning: nil, elements: nil, location: nil) Words.new( beginning: beginning || self.beginning, elements: elements || self.elements, location: location || self.location ) end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { beginning: beginning, elements: elements, location: location, comments: comments } end
def format(q)
def format(q) opening, closing = "%W[", "]" if elements.any? { |element| element.match?(/[\[\]]/) } opening = beginning.value closing = Quotes.matching(opening[2]) end q.text(opening) q.group do q.indent do q.breakable_empty q.seplist( elements, ArrayLiteral::BREAKABLE_SPACE_SEPARATOR ) { |element| q.format(element) } end q.breakable_empty end q.text(closing) end
def initialize(beginning:, elements:, location:)
def initialize(beginning:, elements:, location:) @beginning = beginning @elements = elements @location = location @comments = [] end