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.
1098 1099 1100 |
# File 'lib/syntax_tree/node.rb', line 1098 def initialize(contents) @contents = contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
- Args
-
the contents of the array
1096 1097 1098 |
# File 'lib/syntax_tree/node.rb', line 1096 def contents @contents end |
Instance Method Details
#format(q) ⇒ Object
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 |
# File 'lib/syntax_tree/node.rb', line 1102 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 |