Module: Cloudcost::CsvOutput

Included in:
ServerList, VolumeList
Defined in:
lib/cloudcost/commands/csv_output.rb

Overview

generic CSV output methods

Instance Method Summary collapse

Instance Method Details

#groups_to_csv(group_rows) ⇒ Object



6
7
8
9
10
11
# File 'lib/cloudcost/commands/csv_output.rb', line 6

def groups_to_csv(group_rows)
  CSV.generate do |csv|
    csv << headings
    group_rows.each { |row| csv << row }
  end
end

#to_csvObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/cloudcost/commands/csv_output.rb', line 13

def to_csv
  CSV.generate do |csv|
    csv << headings
    if @options[:summary]
      csv << totals
    else
      rows.each { |row| csv << row }
    end
  end
end