Class: SyntaxTree::ArrayLiteral::QSymbolsFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

Formats an array of multiple simple symbol literals into the %i syntax.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ QSymbolsFormatter

Returns a new instance of QSymbolsFormatter.



824
825
826
# File 'lib/syntax_tree/node.rb', line 824

def initialize(contents)
  @contents = contents
end

Instance Attribute Details

#contentsObject (readonly)

Args

the contents of the array



822
823
824
# File 'lib/syntax_tree/node.rb', line 822

def contents
  @contents
end

Instance Method Details

#format(q) ⇒ Object



828
829
830
831
832
833
834
835
836
837
838
# File 'lib/syntax_tree/node.rb', line 828

def format(q)
  q.group(0, "%i[", "]") do
    q.indent do
      q.breakable("")
      q.seplist(contents.parts, -> { q.breakable }) do |part|
        q.format(part.value)
      end
    end
    q.breakable("")
  end
end