Class: RubyDocx::Convertor::Html::Table

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_docx/convertors/elements/html/table.rb

Instance Attribute Summary

Attributes inherited from Base

#css, #tag

Instance Method Summary collapse

Methods inherited from Base

#build, #initialize, #styles

Constructor Details

This class inherits a constructor from RubyDocx::Convertor::Html::Base

Instance Method Details

#convertObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ruby_docx/convertors/elements/html/table.rb', line 3

def convert
  node = RubyDocx::Table.new
  tag.children.each do |child|
    rows = if %w[thead tbody tfoot].include? child.name
      child.children
    elsif !child.is_a?(Nokogiri::XML::Text)
      [child]
    else
      []
    end
    rows.each do |row|
      node.append RubyDocx::Convertor::Html.create_node(row, css)
    end
  end
  node
end