Class: Vcsmap::CsvWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/vcsmap/csv_writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(plugin_name, plugin_header, data) ⇒ CsvWriter

Returns a new instance of CsvWriter.



5
6
7
8
9
# File 'lib/vcsmap/csv_writer.rb', line 5

def initialize(plugin_name, plugin_header, data)
  @file_path = file_path(plugin_name)
  @header = header(plugin_header)
  @data = data
end

Instance Method Details

#write!Object



11
12
13
14
15
16
17
18
19
# File 'lib/vcsmap/csv_writer.rb', line 11

def write!
  puts "Writing CSV to #{@file_path} ..."
  CSV.open(@file_path, 'wb', force_quotes: true) do |csv|
    csv << @header
    @data.each do |line|
      csv << line
    end
  end
end