Sha256: 21e34c80546364c7101ecaa7fbd2e4e1cb7b306ed33a921ec75397390b62cc2a
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
module Nineteen module Eighty module Two module Formats class HTMLTable 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, blanks: blanks(lines.first), rows: lines.map { |l| row(l) }.join("\n") } Erubis::Eruby.new(t).evaluate(context).strip end 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 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 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 end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nineteen-eighty-two-0.1.3 | lib/nineteen/eighty/two/formatters/html_table_formatter.rb |