Class: SiSU_Tables::TableXMLexp

Inherits:
Table
  • Object
show all
Defined in:
lib/sisu/xml_tables.rb

Constant Summary collapse

@@tablehead =
0
@@tablefoot =
[]

Instance Method Summary collapse

Methods inherited from Table

#table_split

Constructor Details

#initialize(one) ⇒ TableXMLexp

Returns a new instance of TableXMLexp.



177
178
179
# File 'lib/sisu/xml_tables.rb', line 177

def initialize(one)
  @one,@parablock=one,one
end

Instance Method Details

#margin_numlessObject



184
185
186
# File 'lib/sisu/xml_tables.rb', line 184

def margin_numless
  '</td><td width="4%" align="right" valign="top">'
end

#tableObject



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/sisu/xml_tables.rb', line 215

def table
  m=@parablock[/<!f(.+?)!>/,1]
  @@tablefoot << m if m
  @parablock=@parablock.gsub(/<!f.+?!>/,'')
  @@tablehead=1 if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u
  if @parablock =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+);\w\d+;\w\d+#{Mx[:gr_c]}/u
    @parablock=table_head($1)
  end
  if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/
    tablefoot=[]
    @@tablefoot.each {|x| tablefoot << ''}
    @@tablefoot=[]
    if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/
      @parablock=table_end
    end
  end
  if @@tablehead==1
    if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u
      if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
        @parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true))
      end
      if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
        @parablock=@parablock.gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true))
      end
      if @parablock =~/#{Mx[:tc_c]}/
        @parablock=@parablock.gsub(/#{Mx[:tc_c]}/,table_row_close(true))
      end
      @@tablehead=0
    end
    @parablock
  else
    if @parablock =~/^#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
      @parablock=@parablock.gsub(/^#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1))
    end
    if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u
      @parablock=@parablock.gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1))
    end
    if @parablock =~/#{Mx[:tc_c]}/
      @parablock=@parablock.gsub(/#{Mx[:tc_c]}/,table_row_close)
    end
    @parablock
  end
  @parablock
end

#table_cell(inf, h = false) ⇒ Object



206
207
208
209
210
# File 'lib/sisu/xml_tables.rb', line 206

def table_cell(inf,h=false)
  if h; %{</b></td><td width="#{inf}%" valign="top"><b>}
  else  %{</td><td width="#{inf}%" valign="top">}
  end
end

#table_closeObject



180
181
182
183
# File 'lib/sisu/xml_tables.rb', line 180

def table_close
  '</td></tr>
</table>'
end

#table_end(tablefoot = '') ⇒ Object



196
197
198
199
# File 'lib/sisu/xml_tables.rb', line 196

def table_end(tablefoot='')
  %{</table>#{the_margin_numless}#{the_margin_numless}&nbsp;#{the_table_close}
#{tablefoot}}
end

#table_head(inf) ⇒ Object



187
188
189
190
191
192
193
194
195
# File 'lib/sisu/xml_tables.rb', line 187

def table_head(inf)
  %{<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">
  <tr>
<td valign="top" align="justify">
  <a name="#{inf}"></a>
</td>
<td>
<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">}
end

#table_row(inf, h = false) ⇒ Object



200
201
202
203
204
205
# File 'lib/sisu/xml_tables.rb', line 200

def table_row(inf,h=false)
  bold=h ? '<b>' : ''
  %{
<tr>
  <td width="#{inf}%" valign="top">#{bold}}
end

#table_row_close(h = false) ⇒ Object



211
212
213
214
# File 'lib/sisu/xml_tables.rb', line 211

def table_row_close(h=false)
  bold_close=h ? '<b>' : ''
  "#{bold_close}</td></tr>"
end