Class: RuportJsonFormatter
- Inherits:
-
Ruport::Formatter
- Object
- Ruport::Formatter
- RuportJsonFormatter
- Defined in:
- lib/ruport_json_formatter.rb
Instance Method Summary collapse
Instance Method Details
#build_row(row) ⇒ Object
27 28 29 |
# File 'lib/ruport_json_formatter.rb', line 27 def build_row(row) row.to_a.to_json end |
#build_table_body ⇒ Object
21 22 23 24 25 |
# File 'lib/ruport_json_formatter.rb', line 21 def build_table_body buffer = [] data.each { |r| buffer << build_row(r) } output << buffer.join(",\n") end |
#build_table_header ⇒ Object
16 17 18 19 |
# File 'lib/ruport_json_formatter.rb', line 16 def build_table_header output << build_row(data.column_names) output << ",\n" # add a comma for the delimiter for the next row... end |
#layout ⇒ Object
10 11 12 13 14 |
# File 'lib/ruport_json_formatter.rb', line 10 def layout output << "[\n" yield output << "]" end |