class Nineteen::Eighty::Two::Formats::HTMLTable
Public Class Methods
blanks(lines)
click to toggle source
# File lib/nineteen/eighty/two/formatters/html_table_formatter.rb, line 18 def self.blanks lines t = File.read File.open File.join Nineteen::Eighty::Two.templates_dir, 'html', 'table', 'row.eruby' context = { cells: lines.map { |b| cell Span.new(0, 1) }.join } Erubis::Eruby.new(t).evaluate(context).strip end
cell(span)
click to toggle source
# File lib/nineteen/eighty/two/formatters/html_table_formatter.rb, line 26 def self.cell span t = File.read File.open File.join Nineteen::Eighty::Two.templates_dir, 'html', 'table', 'cell.eruby' context = { style: span.type == 1 ? 'on' : 'off', } context[:colspan] = span.width if span.width > 1 Erubis::Eruby.new(t).evaluate(context).strip end
format(text)
click to toggle source
# File lib/nineteen/eighty/two/formatters/html_table_formatter.rb, line 6 def self.format text lines = Spectrum[*text] t = File.read File.open File.join Nineteen::Eighty::Two.templates_dir, 'html', 'table', 'table.eruby' context = { title: text.to_s.gsub('"', ''), blanks: blanks(lines.first), rows: lines.map { |l| row(l) }.join("\n") } Erubis::Eruby.new(t).evaluate(context).strip end
row(list)
click to toggle source
# File lib/nineteen/eighty/two/formatters/html_table_formatter.rb, line 35 def self.row list t = File.read File.open File.join Nineteen::Eighty::Two.templates_dir, 'html', 'table', 'row.eruby' context = { cells: Decorators::RunLengthEncoder.encode(list).map { |i| cell i }.join } Erubis::Eruby.new(t).evaluate(context).strip end