Class: Hash

Inherits:
Object show all
Defined in:
lib/Hash/blankQ.rb,
lib/Hash/to_csv.rb

Overview

History: Stolen wholesale from ActiveSupport.

Instance Method Summary collapse

Instance Method Details

#to_csv(*args) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/Hash/to_csv.rb', line 21

def to_csv(*args)
  options = args.extract_options!
  quote = options[:quote]
  selected_columns = options[:selected_columns]
  collector = []
  if selected_columns
    selected_columns.each{|column| collector << self[column]}
  else
    self.each{|k,v| collector << self[v]}
  end
  collector.to_csv(quote)
end