Skip to content
schacon edited this page Sep 12, 2010 · 5 revisions

This is where you take your nicely constructed MungerReport object and make it render into a useful format.

Right now there are only 2 renderers, but it’s pretty easy to write one, so more will come soon.

HTML

You can either use the Munger::Render.to_X form, like so:

html_table = Munger::Render.to_html(report)

Or you can do this:

html_table = Munger::Render::Html.new(report).render

That will give you html table text – also to note is that the table has the class ‘report-table’, every other TR has a ‘even’ / ‘odd’ class, and each grouping row TR has a ‘group0’, ‘group1’, ‘group2’, etc class. You can use those to style your table. You can also override the main table class like this:

html_table = Munger::Render.to_html(report, :classes => {:table => 'other-class'} )

Text

You can also get text based output like this:

puts text = Munger::Render.to_text(report)

Which is what I’ve been using through this tutorial, and looks like this:


|Spot | Rate | Air Date | Airtime |
-——————————————————-
|Spot 2 | 14 | 2008-01-02 | 15 |
|Spot 1 | 20 | 2008-01-01 | 15 |
|Spot 3 | 22 | 2008-01-03 | 15 |
|Spot 1 | 22 | 2008-01-04 | 15 |
|Spot 2 | 5 | 2008-01-01 | 30 |
|Spot 1 | 6 | 2008-01-02 | 30 |
|Spot 1 | 7 | 2008-01-03 | 30 |
|Spot 2 | 10 | 2008-01-04 | 30 |
|Spot 3 | 27 | 2008-01-02 | 30 |
|Spot 3 | 8 | 2008-01-01 | 60 |
|Spot 2 | 11 | 2008-01-03 | 90 |

Future

  • XLS
  • CSV
  • PDF

Clone this wiki locally