Module: SendCsv
- Defined in:
- lib/send_csv.rb
Defined Under Namespace
Classes: Engine
Constant Summary collapse
- VERSION =
'0.6'
Class Method Summary collapse
Class Method Details
.generate_csv(lines, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/send_csv.rb', line 5 def generate_csv(lines, = {}) require 'csv' = .dup encoding = .delete(:encoding) || 'ISO-8859-15' csv = lines.map { |values| CSV.generate_line(values, :col_sep => ';', :row_sep => "\r\n") }.join csv = csv.encode(encoding, :invalid => :replace, :undef => :replace) csv end |
.send_csv(lines, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/send_csv.rb', line 17 def send_csv(lines, = {}) = .dup = { :disposition => "attachment", :type => 'text/csv', }.merge() csv = generate_csv(lines, ) send_data csv, end |