Class: Tex::Table
- Inherits:
-
Object
- Object
- Tex::Table
- Defined in:
- lib/rbtex.rb
Instance Method Summary collapse
- #colSum(col) ⇒ Object
- #create ⇒ Object
-
#initialize(twodee, tabx = false) ⇒ Table
constructor
A new instance of Table.
- #rowSum(row) ⇒ Object
Constructor Details
#initialize(twodee, tabx = false) ⇒ Table
Returns a new instance of Table.
68 69 70 71 72 |
# File 'lib/rbtex.rb', line 68 def initialize(twodee, tabx=false) @array = twodee # @rowlines = rowlines @tabx = tabx end |
Instance Method Details
#colSum(col) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# 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 ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# 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) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/rbtex.rb', line 108 def rowSum row total = 0 @array[row].each do |elem| total = total + elem end end |