Class: RubyDocx::Paragraph
- Inherits:
-
Block
- Object
- InextensibleBlock
- Block
- RubyDocx::Paragraph
- Defined in:
- lib/ruby_docx/elements/paragraph.rb
Instance Attribute Summary
Attributes inherited from Block
Attributes inherited from InextensibleBlock
Instance Method Summary collapse
Methods inherited from Block
#append, #initialize, #prepend
Methods inherited from InextensibleBlock
Constructor Details
This class inherits a constructor from RubyDocx::Block
Instance Method Details
#build ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ruby_docx/elements/paragraph.rb', line 3 def build # doc = RubyDocx::Convertor::Html.convert(nil); puts doc.render # doc = RubyDocx::Convertor::Html.convert(nil); doc.save('/Users/Homer/Temp/creating.docx') set = [] node = build_node apply_styles node set << node @children.each do |child| if child.is_a?(self.class) child_set = child.build unless child_set.all? { |cnode| cnode.name == 'p' && cnode.children.empty? } child_set.each { |item| set << item } end elsif child.is_a?(RubyDocx::Table) set << child.build elsif (child.is_a?(RubyDocx::Row) || child.is_a?(RubyDocx::Br) || child.is_a?(RubyDocx::Hyperlink)) && set.size > 1 RubyDocx::Paragraph.new(nil, styles, [child]).build.each { |item| set << item } else node.add_child child.build end end delete_empty_nodes set node_set = Nokogiri::XML::NodeSet.new( document || Nokogiri::XML::Document.new ) set.each { |item| node_set << item } node_set end |