Class: SiSU_Tables::TableXMLdocbook
- Inherits:
-
Object
- Object
- SiSU_Tables::TableXMLdocbook
- Defined in:
- lib/sisu/xml_tables.rb
Constant Summary collapse
- @@tablehead =
0
- @@tablefoot =
watch
[]
Instance Method Summary collapse
-
#initialize(table, id = '') ⇒ TableXMLdocbook
constructor
A new instance of TableXMLdocbook.
- #spaces ⇒ Object
- #table ⇒ Object
-
#table_rows_and_columns_array(table_obj) ⇒ Object
provides basic (x)html table.
Constructor Details
#initialize(table, id = '') ⇒ TableXMLdocbook
Returns a new instance of TableXMLdocbook.
120 121 122 |
# File 'lib/sisu/xml_tables.rb', line 120 def initialize(table,id='') @table_obj,@id=table,id end |
Instance Method Details
#spaces ⇒ Object
123 124 125 |
# File 'lib/sisu/xml_tables.rb', line 123 def spaces Ax[:spaces] end |
#table ⇒ Object
126 127 128 129 130 131 132 133 |
# File 'lib/sisu/xml_tables.rb', line 126 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
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/sisu/xml_tables.rb', line 134 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(/ /,' '). gsub(/<:br>/,'<br />') trc <<= if table_obj.head_ and nr==0 %{#{spaces*6}<entry>#{c}</entry>\n} else %{#{spaces*6}<entry>#{c}</entry>\n} end nc+=1 end trc=(trc.is_a?(Array)) ? trc.flatten.join : trc trc = if table_obj.head_ and nr==0 "#{spaces*4}<thead>\n#{spaces*5}<row>\n#{trc}#{spaces*5}</row>\n#{spaces*4}</thead>\n#{spaces*4}<tbody>\n" else "#{spaces*5}<row>\n#{trc}#{spaces*5}</row>\n" end nr+=1 table_rows << trc end tbody_close=if table_obj.head_ "#{spaces*4}</tbody>" else '' end table_rows=table_rows.flatten.join # include table_id <table id=''> table_obj.obj=%{#{spaces*3}<para #{@id}> #{spaces*4}<table> #{spaces*4}<tgroup cols="#{table_obj.cols}" align="char"> #{table_rows}#{tbody_close} #{spaces*4}</tgroup> #{spaces*4}</table> #{spaces*3}</para>} table_obj end |