Class: Array

Inherits:
Object show all
Defined in:
lib/comma.rb

Instance Method Summary collapse

Instance Method Details

#to_comma(style = :default) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/comma.rb', line 12

def to_comma(style = :default)
  options = {}

  if style.is_a? Hash
    options = style
    style = options.delete(:style)||:default
  end

  FasterCSV.generate(options) do |csv|
    return "" if empty?
    csv << first.to_comma_headers(style) # REVISIT: request to optionally include headers
    each do |object| 
      csv << object.to_comma(style)
    end
  end
end