class Docxtor2::Package::Document::Paragraph
Public Class Methods
new(*args, &block)
click to toggle source
Calls superclass method
Docxtor2::Package::Document::Element::new
# File lib/docxtor2/package/document/paragraph.rb, line 3 def initialize(*args, &block) super(*args, &block) Known::Mappings::PARAGRAPH_COMPLEX.each do |name, element| @params[name] ||= {} end @params[:space] ||= 'default' @contents = create_contents(args) end
Public Instance Methods
line_break()
click to toggle source
# File lib/docxtor2/package/document/paragraph.rb, line 31 def line_break @contents << :br end
Also aliased as: br
preserve_whitespace()
click to toggle source
# File lib/docxtor2/package/document/paragraph.rb, line 35 def preserve_whitespace @params[:space] = 'preserve' end
render(xml)
click to toggle source
Calls superclass method
Docxtor2::Package::Document::Element#render
# File lib/docxtor2/package/document/paragraph.rb, line 12 def render(xml) super(xml) write_element(:p) do write_element(:r) do write_contents end end end
write(text)
click to toggle source
# File lib/docxtor2/package/document/paragraph.rb, line 39 def write(text) @contents << text end
Also aliased as: w
Protected Instance Methods
aliases()
click to toggle source
Calls superclass method
Docxtor2::Package::Document::Element#aliases
# File lib/docxtor2/package/document/paragraph.rb, line 52 def aliases super.merge(Known::Aliases::PARAGRAPH) end
mappings()
click to toggle source
Calls superclass method
Docxtor2::Package::Document::Element#mappings
# File lib/docxtor2/package/document/paragraph.rb, line 45 def mappings super.merge({ :p => Known::Mappings::PARAGRAPH, :r => Known::Mappings::RUN }) end
Private Instance Methods
create_contents(args)
click to toggle source
# File lib/docxtor2/package/document/paragraph.rb, line 78 def create_contents(args) str = find_argument(args, String) str.nil? ? [] : [str] end
write_content(content)
click to toggle source
# File lib/docxtor2/package/document/paragraph.rb, line 62 def write_content(content) content == :br ? write_line_break : write_text(content) end
write_contents()
click to toggle source
# File lib/docxtor2/package/document/paragraph.rb, line 58 def write_contents @contents.each { |c| write_content(c) } end
write_line_break()
click to toggle source
# File lib/docxtor2/package/document/paragraph.rb, line 68 def write_line_break @xml.w :br end
write_text(text)
click to toggle source
# File lib/docxtor2/package/document/paragraph.rb, line 72 def write_text(text) @xml.w :t, 'xml:space' => @params[:space] do @xml.text! text end end