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.



852
853
854
# File 'lib/syntax_tree/node.rb', line 852

def initialize(contents)
  @contents = contents
end

Instance Attribute Details

#contentsObject (readonly)

Args

the contents of the array



850
851
852
# File 'lib/syntax_tree/node.rb', line 850

def contents
  @contents
end

Instance Method Details

#format(q) ⇒ Object



856
857
858
859
860
861
862
863
864
865
866
867
868
# File 'lib/syntax_tree/node.rb', line 856

def format(q)
  q.text("%i[")
  q.group do
    q.indent do
      q.breakable_empty
      q.seplist(contents.parts, BREAKABLE_SPACE_SEPARATOR) do |part|
        q.format(part.value)
      end
    end
    q.breakable_empty
  end
  q.text("]")
end