Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/csvify.rb
Instance Method Summary collapse
Instance Method Details
#to_csv ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/csvify.rb', line 3 def to_csv columns = self.first.class.column_names data = "" self.each do |o| columns.each_with_index do |c, i| if i < columns.length-1 data << "'#{o.send(c.to_s).to_s.strip}', " else data << "'#{o.send(c.to_s).to_s.strip}'" end end data << "\n" end return data end |