Class: Taql::Formatter
- Inherits:
-
Object
- Object
- Taql::Formatter
- Defined in:
- lib/taql/formatter.rb
Constant Summary collapse
- DASH =
"-".freeze
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(entries) ⇒ Formatter
constructor
A new instance of Formatter.
- #print ⇒ Object (also: #to_s)
Constructor Details
#initialize(entries) ⇒ Formatter
Returns a new instance of Formatter.
5 6 7 |
# File 'lib/taql/formatter.rb', line 5 def initialize(entries) @entries = entries.map { |entry| entry.transform_values(&:to_s) } end |
Instance Method Details
#headers ⇒ Object
9 10 11 |
# File 'lib/taql/formatter.rb', line 9 def headers @headers ||= entries.flat_map(&:keys).uniq end |
#print ⇒ Object Also known as: to_s
13 14 15 |
# File 'lib/taql/formatter.rb', line 13 def print output if entries.any? end |