Class: Munger::Render::CSV
- Inherits:
-
Object
- Object
- Munger::Render::CSV
- Defined in:
- lib/munger/render/csv.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#report ⇒ Object
readonly
Returns the value of attribute report.
Instance Method Summary collapse
-
#initialize(report) ⇒ CSV
constructor
A new instance of CSV.
- #render ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(report) ⇒ CSV
Returns a new instance of CSV.
7 8 9 |
# File 'lib/munger/render/csv.rb', line 7 def initialize(report) @report = report end |
Instance Attribute Details
#report ⇒ Object (readonly)
Returns the value of attribute report.
5 6 7 |
# File 'lib/munger/render/csv.rb', line 5 def report @report end |
Instance Method Details
#render ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/munger/render/csv.rb', line 11 def render output = [] # header output << @report.columns.collect { |col| @report.column_title(col).to_s }.join(',') # body @report.process_data.each do |row| output << @report.columns.collect { |col| row[:data][col].to_s }.join(',') end output.join("\n") end |