class SyntaxTree::ArrayLiteral::QWordsFormatter

Formats an array of multiple simple string literals into the %w syntax.

Attributes

contents[R]
Args

the contents of the array

Public Class Methods

new(contents) click to toggle source
# File lib/syntax_tree/node.rb, line 1070
def initialize(contents)
  @contents = contents
end

Public Instance Methods

format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 1074
def format(q)
  q.text("%w[")
  q.group do
    q.indent do
      q.breakable_empty
      q.seplist(contents.parts, BREAKABLE_SPACE_SEPARATOR) do |part|
        if part.is_a?(StringLiteral)
          q.format(part.parts.first)
        else
          q.text(part.value[1..])
        end
      end
    end
    q.breakable_empty
  end
  q.text("]")
end