class StHtmlTable::Cell
Attributes
align[RW]
bold[RW]
col_id[RW]
cols[RW]
is_header[RW]
italic[RW]
row[R]
row_id[RW]
table[R]
text[RW]
type[RW]
valign[RW]
Public Class Methods
new(table, row)
click to toggle source
# File lib/st_html_table/cell.rb, line 16 def initialize(table, row) @text = ' ' @row = row @table = table @is_header = false @cols = 1 @col_id = 0 @row_id = 0 @type = :neutral @valign = :top @bold = false @italic = false @align = :left @ident = 6 end
Public Instance Methods
prefix=(value)
click to toggle source
# File lib/st_html_table/cell.rb, line 34 def prefix=(value) @prefix = value end
suffix=(value)
click to toggle source
# File lib/st_html_table/cell.rb, line 38 def suffix=(value) @suffix = value end
to_html()
click to toggle source
# File lib/st_html_table/cell.rb, line 46 def to_html type = @is_header ? 'th' : 'td' out = Array.new out << (' ' * @ident) + build_cell_arguments(type) out << (' ' * (@ident + 2)) + @text.to_s out << (' ' * @ident) + "</#{type}>" out.join("\n") end
to_s()
click to toggle source
# File lib/st_html_table/cell.rb, line 42 def to_s @text.gsub(%r{</?[^>]+?>}, '') end
Private Instance Methods
build_cell_arguments(type)
click to toggle source
# File lib/st_html_table/cell.rb, line 59 def build_cell_arguments(type) out = Array.new style = Array.new style << "font-weight:bold;" if @bold style << "font-style:italic;" if @italic style << "border: 1px solid #eaeaea;" out << "align=#{@align.to_s.inspect}" out << "valign=#{@valign.to_s.inspect}" if @valign != :top out << "style='#{style.join}'" unless style.empty? out << "cols=\"#{@cols}\"" if @cols != 1 "<#{type} " + out.join(' ') + ">" end