Class: Mpql::Formatters::TableFormatter
- Inherits:
-
Object
- Object
- Mpql::Formatters::TableFormatter
- Defined in:
- lib/mpql/formatters/table_formatter.rb
Instance Method Summary collapse
-
#initialize(data) ⇒ TableFormatter
constructor
A new instance of TableFormatter.
- #render ⇒ Object
Constructor Details
#initialize(data) ⇒ TableFormatter
Returns a new instance of TableFormatter.
10 11 12 |
# File 'lib/mpql/formatters/table_formatter.rb', line 10 def initialize(data) @builder = RowBuilder.new(data) end |
Instance Method Details
#render ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/mpql/formatters/table_formatter.rb', line 14 def render table = Terminal::Table.new( headings: @builder.headers, rows: @builder.rows.map { |row| row.map { |v| format_value(v) } } ) table.to_s end |