require 'csv'
module PanicBoardData
class Table
attr_accessor :data, :widths
def to_html
result = "
"
if data
data.each do |record|
result << ""
record.each_with_index do |item, index|
if widths && widths[index]
result << "#{item} | "
else
result << "#{item} | "
end
end
result << "
"
end
end
result << "
"
end
def self.to_csv data
::CSV.generate do |csv|
data.each { |row| csv << row }
end.strip
end
end
end