Class: Docxer::Word::Contents::Paragraph
- Inherits:
-
Object
- Object
- Docxer::Word::Contents::Paragraph
- Defined in:
- lib/docxer/word/contents/paragraph.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #br(options = {}) ⇒ Object
- #image(image, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Paragraph
constructor
A new instance of Paragraph.
- #render(xml) ⇒ Object
- #text(text, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Paragraph
Returns a new instance of Paragraph.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/docxer/word/contents/paragraph.rb', line 8 def initialize(={}) @content = [] @options = if block_given? yield self else end end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
7 8 9 |
# File 'lib/docxer/word/contents/paragraph.rb', line 7 def content @content end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/docxer/word/contents/paragraph.rb', line 7 def @options end |
Instance Method Details
#br(options = {}) ⇒ Object
43 44 45 46 47 |
# File 'lib/docxer/word/contents/paragraph.rb', line 43 def br(={}) br = Docxer::Word::Contents::Break.new() @content << br br end |
#image(image, options = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/docxer/word/contents/paragraph.rb', line 49 def image(image, ={}) img = Docxer::Word::Contents::Image.new(image, ) @content << img img end |
#render(xml) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/docxer/word/contents/paragraph.rb', line 19 def render(xml) xml['w'].p do xml['w'].pPr do xml['w'].jc( 'w:val' => @options[:align]) if @options[:align] if [:ul] xml['w'].numPr do xml['w'].ilvl( 'w:val' => 0 ) xml['w'].numId( 'w:val' => 1 ) end end end @content.each do |element| element.render(xml) end end end |