Class: Compendium::Presenters::CSV
- Defined in:
- app/classes/compendium/presenters/csv.rb
Instance Attribute Summary
Attributes inherited from Table
Instance Method Summary collapse
-
#initialize(object, &block) ⇒ CSV
constructor
A new instance of CSV.
- #render ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(object, &block) ⇒ CSV
Returns a new instance of CSV.
5 6 7 |
# File 'app/classes/compendium/presenters/csv.rb', line 5 def initialize(object, &block) super(nil, object, &block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Compendium::Presenters::Base
Instance Method Details
#render ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/classes/compendium/presenters/csv.rb', line 9 def render ::CSV.generate do |csv| csv << headings.map{ |_, val| formatted_heading(val) } records.each do |row| csv << row.map{ |key, val| formatted_value(key, val) } end if has_totals_row? totals[totals.keys.first] = translate(:total) csv << totals.map do |key, val| formatted_value(key, val) unless settings.skipped_total_cols.include?(key.to_sym) end end end end |