Class: JCF::CLI::OutputFormatters::CSV

Inherits:
Object
  • Object
show all
Defined in:
lib/jcf/cli/output_formatters/csv.rb

Class Method Summary collapse

Class Method Details

.format(data:) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/jcf/cli/output_formatters/csv.rb', line 10

def format(data:)
  return "" if data.nil? || data.empty?

  ::CSV.generate(headers: data.keys, write_headers: true) do |csv|
    data.values.transpose.each do |value|
      csv << value
    end
  end
end