Class: DefMastership::CSVFormatter
- Inherits:
-
Object
- Object
- DefMastership::CSVFormatter
- Defined in:
- lib/defmastership/csv_formatter.rb
Overview
to export a CSV file
Instance Method Summary collapse
- #export_to(output_file) ⇒ Object
-
#initialize(doc, sep = ',') ⇒ CSVFormatter
constructor
A new instance of CSVFormatter.
Constructor Details
#initialize(doc, sep = ',') ⇒ CSVFormatter
Returns a new instance of CSVFormatter.
11 12 13 14 |
# File 'lib/defmastership/csv_formatter.rb', line 11 def initialize(doc, sep = ',') @doc = doc @sep = sep end |
Instance Method Details
#export_to(output_file) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/defmastership/csv_formatter.rb', line 16 def export_to(output_file) column_list = build_column_list CSV.open(output_file, 'w:ISO-8859-1', { col_sep: @sep }) do |csv| csv << header(column_list) @doc.definitions.each { |definition| csv << body(definition, column_list) } end end |