Class: CSVResponse
- Inherits:
-
Object
- Object
- CSVResponse
- Defined in:
- backend/app/lib/reports/csv_response.rb
Instance Method Summary (collapse)
-
- (Object) each {|@report.headers.to_csv| ... }
-
- (Object) generate
just added for the generic response.
-
- (CSVResponse) initialize(report, params = {})
constructor
A new instance of CSVResponse.
Constructor Details
- (CSVResponse) initialize(report, params = {})
Returns a new instance of CSVResponse
5 6 7 |
# File 'backend/app/lib/reports/csv_response.rb', line 5 def initialize(report, params = {} ) @report = report end |
Instance Method Details
- (Object) each {|@report.headers.to_csv| ... }
9 10 11 12 13 14 15 |
# File 'backend/app/lib/reports/csv_response.rb', line 9 def each yield @report.headers.to_csv @report.each do |row| yield @report.headers.map{|h| row[h]}.to_csv end end |
- (Object) generate
just added for the generic response
18 19 20 21 |
# File 'backend/app/lib/reports/csv_response.rb', line 18 def generate output = "" self.each { |r| output << r } end |