class RubyDocx::Elements::Table
Public Instance Methods
to_html()
click to toggle source
# File lib/ruby_docx/elements/table.rb, line 19 def to_html s = "<table>" self.trs.each_with_index do |tr, i| if self.grid w = self.grid.width_of(i).to_i end s += "<tr>" tr.cells.map do |cell| if w.to_i > 0 s += "<td style='width: #{(w/100.0).round(2)}%'>#{cell.to_html}</td>" else s += "<td>#{cell.to_html}</td>" end end s += "</tr>" end s += "</table>" s end
to_s()
click to toggle source
# File lib/ruby_docx/elements/table.rb, line 4 def to_s s = "\n" self.trs.map do |tr| tr.cells.map do |cell| s += "#{cell.to_s}\t" end s += "\n" end s += "\n" s end
trs()
click to toggle source
# File lib/ruby_docx/elements/table.rb, line 46 def trs self.elements end