Class: Mpql::Formatters::TsvFormatter
- Inherits:
-
Object
- Object
- Mpql::Formatters::TsvFormatter
- Defined in:
- lib/mpql/formatters/tsv_formatter.rb
Instance Method Summary collapse
-
#initialize(data) ⇒ TsvFormatter
constructor
A new instance of TsvFormatter.
- #render ⇒ Object
Constructor Details
#initialize(data) ⇒ TsvFormatter
Returns a new instance of TsvFormatter.
9 10 11 |
# File 'lib/mpql/formatters/tsv_formatter.rb', line 9 def initialize(data) @builder = RowBuilder.new(data) end |
Instance Method Details
#render ⇒ Object
13 14 15 16 17 18 |
# File 'lib/mpql/formatters/tsv_formatter.rb', line 13 def render lines = [] lines << @builder.headers.join("\t") if @builder.headers @builder.rows.each { |row| lines << row.map { |v| format_value(v) }.join("\t") } lines.join("\n") end |