Sha256: 5919a1fbb2dcc0d818c5666a4fdb31269b7cf69992f7d4970162418fb85f795c
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
require 'csv' module PanicBoardData class Table attr_accessor :data, :widths, :base_image_url def build_image value url = [self.base_image_url, value] .select { |x| x.to_s != '' } .map { |x| x.to_s.strip } .map { |x| x.gsub('/', '') } .join('/') .gsub('http:', 'http://') .gsub('https:', 'https://') "<img src=\"#{url}\" />" end def to_html result = "<table>" if data data.each do |record| result << "<tr>" record.each_with_index do |value, index| value = value.join('') if value.is_a?(Array) if widths && widths[index] result << "<td style=\"width: #{widths[index]}px\">#{value}</td>" else result << "<td>#{value}</td>" end 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.8 | lib/panic_board_data/table.rb |