Class: RubyDocx::Elements::TableCell

Inherits:
Element
  • Object
show all
Defined in:
lib/ruby_docx/elements/table_cell.rb

Instance Attribute Summary

Attributes inherited from Element

#doc, #grid, #node, #style

Instance Method Summary collapse

Methods inherited from Element

#elements, #initialize, #inspect, #to_xml

Constructor Details

This class inherits a constructor from RubyDocx::Elements::Element

Instance Method Details

#inner_htmlObject



8
9
10
# File 'lib/ruby_docx/elements/table_cell.rb', line 8

def inner_html
  "#{self.elements.map(&:to_html).join}"
end

#to_htmlObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ruby_docx/elements/table_cell.rb', line 12

def to_html
  w = 0
  if self.style
    w = self.style.width.to_i
  end

  if w > 0
    "<td style='width: #{(w/100.0).round(2)}%'>#{self.elements.map(&:to_html).join}</td>"
  else
    "<td>#{self.elements.map(&:to_html).join}</td>"
  end
end

#to_sObject



4
5
6
# File 'lib/ruby_docx/elements/table_cell.rb', line 4

def to_s
  self.elements.map(&:to_s).join
end