class Passcard::HtmlOutputter
Public Instance Methods
to_html(options = {})
click to toggle source
# File lib/passcard/outputter/html_outputter.rb, line 5 def to_html(options = {}) html = "" get_grid(options) use_palette options[:color] html += get_col_headers if options[:header] grid.row_size.times.map do |i| html += "<div class='row'>" html += get_row_header(i) if options[:header] html += get_row(i, options[:color]) html += "</div>" end data = data_in(__FILE__).gsub('{{GRID}}', html) data = data.gsub('{{BACKGROUND}}', get_background) if options[:color] data end
Private Instance Methods
get_background()
click to toggle source
# File lib/passcard/outputter/html_outputter.rb, line 26 def get_background bg1= "rgb(#{@palette.colors[0][:color].join(",")})" bg2= "rgb(#{@palette.colors[-1][:color].join(",")})" "background:linear-gradient(#{bg2},#{bg1})" end
get_col_headers()
click to toggle source
# File lib/passcard/outputter/html_outputter.rb, line 55 def get_col_headers <<-HTML <div class='col-header'> <span>#{col_headers.join("</span><span>")}</span> </div> HTML end
get_row(idx, colors=true)
click to toggle source
# File lib/passcard/outputter/html_outputter.rb, line 39 def get_row(idx, colors=true) <<-HTML <div class='row-content' #{get_style(idx, colors)}> <span>#{grid[idx].to_a.join("</span><span>")}</span> </div> HTML end
get_row_header(i)
click to toggle source
# File lib/passcard/outputter/html_outputter.rb, line 47 def get_row_header(i) <<-HTML <div class='row-header'> <span>#{row_headers[i]}</span> </div> HTML end
get_style(idx, colors = true)
click to toggle source
# File lib/passcard/outputter/html_outputter.rb, line 32 def get_style(idx, colors = true) return unless colors color = "rgb(#{@palette.colors[idx][:color].join(",")})" textc = "rgb(#{@palette.colors[idx][:text_color].join(",")})" return "style='color: #{textc}; background: #{color}'" end