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
1087 1088 1089 |
# File 'lib/syntax_tree/node.rb', line 1087 def initialize(contents) @contents = contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
- Args
-
the contents of the array
1085 1086 1087 |
# File 'lib/syntax_tree/node.rb', line 1085 def contents @contents end |
Instance Method Details
#format(q) ⇒ Object
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 |
# File 'lib/syntax_tree/node.rb', line 1091 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 |