Class: SyntaxTree::ArrayLiteral::QSymbolsFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::ArrayLiteral::QSymbolsFormatter
- Defined in:
- lib/syntax_tree/node.rb
Overview
Formats an array of multiple simple symbol literals into the %i syntax.
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
- Args
-
the contents of the array.
Instance Method Summary collapse
- #format(q) ⇒ Object
-
#initialize(contents) ⇒ QSymbolsFormatter
constructor
A new instance of QSymbolsFormatter.
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
#contents ⇒ Object (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 |