Sha256: 6418653fe89dd877dec6d76f4edbc6a96e7fbb2d9c5382a74deb4d815b3e0055

Contents?: true

Size: 492 Bytes

Versions: 1

Compression:

Stored size: 492 Bytes

Contents

require 'csv'

module PanicBoardData
  class Table

    attr_accessor :data

    def to_html
      result = "<table>"

      if data
        data.each do |record|
          result << "<tr>"
          record.each do |item|
            result << "<td>#{item}</td>"
          end
          result << "</tr>"
        end
      end

      result << "</table>"
    end

    def self.to_csv data
      ::CSV.generate do |csv|
        data.each { |row| csv << row }
      end.strip
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
panic_board_data-0.0.6 lib/panic_board_data/table.rb