Class: SiSU_XHTML_Table::TableXHTML

Inherits:
Object
  • Object
show all
Includes:
SiSU_Parts_XHTML
Defined in:
lib/sisu/xhtml_table.rb

Constant Summary collapse

@@tablefoot =

watch

[]

Instance Method Summary collapse

Methods included from SiSU_Parts_XHTML

#css, #home, #num_css, #paragraph_font_small, #paragraph_font_tiny, #set_fonts, #set_small, #set_tiny, #site, #the_font, #the_line_break, #the_margin, #the_nav, #the_table_close, #the_url, #the_url_decoration, #txt_0, #txt_1, #txt_2, #txt_3, #txt_close, #txt_concordance, #txt_manifest, #txt_open, #txt_toc_link, #xml_close, #xml_open

Methods included from SiSU_Parts_Generic

#footer_signature, #home, #home_txt, #i_choice, #i_home_button, #i_ico, #i_new, #rl_root, #root_http, #sisu, #sisu_txt, #sisudoc, #site, #the_icon, #the_text, #the_url, #txt_home, #txt_hp, #txt_hp_alias, #txt_signature, #urify, #url_close, #url_open

Constructor Details

#initialize(table) ⇒ TableXHTML

Returns a new instance of TableXHTML.



62
63
64
# File 'lib/sisu/xhtml_table.rb', line 62

def initialize(table)
  @table_obj=table
end

Instance Method Details

#tableObject



65
66
67
68
69
70
71
72
# File 'lib/sisu/xhtml_table.rb', line 65

def table
  table_obj=@table_obj
  if table_obj.obj !~/^<table\s/m
    table_obj=table_rows_and_columns_array(table_obj)
  else p __LINE__; p caller
  end
  table_obj
end

#table_rows_and_columns_array(table_obj) ⇒ Object

provides basic (x)html table



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/sisu/xhtml_table.rb', line 73

def table_rows_and_columns_array(table_obj) # provides basic (x)html table
  table_rows,nr=[],0
  table_obj.obj.split(Mx[:tc_c]).each do |table_row|
    table_row_with_columns=table_row.split(Mx[:tc_p])
    trc,nc=[],0
    table_row_with_columns.each do |c|
      c=c.gsub(/^~$/,''). # tilde / empty cell
        gsub(/<:br>/,the_line_break)
      trc <<= if table_obj.head_ and nr==0; %{<th width="#{table_obj.widths[nc]}%">#{c}</th>}
      else %{<td width="#{table_obj.widths[nc]}%">#{c}</td>}
      end
      nc+=1
    end
    trc=(trc.is_a?(Array)) ? trc.flatten.join : trc
    trc="      <tr>#{trc}</tr>\n"
    nr+=1
    table_rows << trc
  end
  table_rows=table_rows.flatten.join
  table_obj.obj=%{<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">\n#{table_rows}    </table>}
  table_obj
end