Class: Docxtor2::Package::Document::Paragraph
- Inherits:
-
Element
- Object
- ElementList
- Element
- Docxtor2::Package::Document::Paragraph
- Defined in:
- lib/docxtor2/package/document/paragraph.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(*args, &block) ⇒ Paragraph
constructor
A new instance of Paragraph.
- #line_break ⇒ Object (also: #br)
- #preserve_whitespace ⇒ Object
- #render(xml) ⇒ Object
- #write(text) ⇒ Object (also: #w)
Methods included from ObjectUtils
Methods included from BlockEvaluator
Methods inherited from ElementList
Constructor Details
#initialize(*args, &block) ⇒ Paragraph
Returns a new instance of Paragraph.
3 4 5 6 7 8 9 10 |
# 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 |
Instance Method Details
#line_break ⇒ Object Also known as: br
31 32 33 |
# File 'lib/docxtor2/package/document/paragraph.rb', line 31 def line_break @contents << :br end |
#preserve_whitespace ⇒ Object
35 36 37 |
# File 'lib/docxtor2/package/document/paragraph.rb', line 35 def preserve_whitespace @params[:space] = 'preserve' end |
#render(xml) ⇒ Object
12 13 14 15 16 17 18 19 |
# 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) ⇒ Object Also known as: w
39 40 41 |
# File 'lib/docxtor2/package/document/paragraph.rb', line 39 def write(text) @contents << text end |