class Tex::Table
Public Class Methods
new(twodee, tabx=false)
click to toggle source
# File lib/rbtex.rb, line 68 def initialize(twodee, tabx=false) @array = twodee # @rowlines = rowlines @tabx = tabx end
Public Instance Methods
colSum(col)
click to toggle source
# File lib/rbtex.rb, line 98 def colSum col total = 0 i = 0 while i < @array.length total = total + @array[i][col] i = i + 1 end return total end
create()
click to toggle source
# File lib/rbtex.rb, line 74 def create pme = "\\begin{#{@tabx ? "tabularx" : "tabular"}}#{@tabx ? "{\\textwidth}" : ""}{|" i = 0 while i < @array[0].length pme << "#{@tabx ? "X|" : "c|"}" i = i + 1 end pme << "} " @array.each do |row| pme << "\\hline " rc = 0 row.each do |elem| pme << " #{elem} " if rc < row.length - 1 pme << "&" end rc = rc + 1 end pme << "\\\\ " end pme << "\\hline \\end{#{@tabx ? "tabularx" : "tabular"}}" return pme end
rowSum(row)
click to toggle source
# File lib/rbtex.rb, line 108 def rowSum row total = 0 @array[row].each do |elem| total = total + elem end end