Class: Cc::Api::Presentor::CSVer

Inherits:
Object
  • Object
show all
Defined in:
lib/cc/api/presentor/presentor.rb

Class Method Summary collapse

Class Method Details

.to_csv(result, file, offset, limit) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/cc/api/presentor/presentor.rb', line 33

def self.to_csv result, file, offset, limit

  CSV.open file, "wb" do |csv|
    csv << result.first.keys
    result.drop(offset || 0).each_with_index do |row, i|
      break if limit && i > limit-1
      csv << row.values
    end
  end
end