Class: ActiveReporter::Serializer::Csv

Inherits:
Table
  • Object
show all
Defined in:
lib/active_reporter/serializer/csv.rb

Instance Attribute Summary

Attributes inherited from Base

#report

Instance Method Summary collapse

Methods inherited from Table

#caption, #each_row, #headers

Methods inherited from Base

#axis_summary, #filter_summary, #human_aggregator_label, #human_aggregator_value_label, #human_category_value_label, #human_dimension_label, #human_dimension_value_label, #human_null_value_label, #human_number_value_label, #human_time_value_label, #initialize, #record_type, #time_formats

Constructor Details

This class inherits a constructor from ActiveReporter::Serializer::Base

Instance Method Details

#csv_textObject



6
7
8
9
10
11
# File 'lib/active_reporter/serializer/csv.rb', line 6

def csv_text
  CSV.generate do |csv|
    csv << headers
    each_row { |row| csv << row }
  end
end

#filenameObject



17
18
19
# File 'lib/active_reporter/serializer/csv.rb', line 17

def filename
  "#{caption.parameterize}.csv"
end

#save(filename = self.filename) ⇒ Object



13
14
15
# File 'lib/active_reporter/serializer/csv.rb', line 13

def save(filename = self.filename)
  File.open(filename, 'w') { |f| f.write data }
end