Class: Docxi::Word::Contents::Paragraph
- Inherits:
-
Object
- Object
- Docxi::Word::Contents::Paragraph
- Defined in:
- lib/docxi/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/docxi/word/contents/paragraph.rb', line 8 def initialize(={}) @content = [] = if block_given? yield self else end end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
7 8 9 |
# File 'lib/docxi/word/contents/paragraph.rb', line 7 def content @content end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/docxi/word/contents/paragraph.rb', line 7 def end |
Instance Method Details
#br(options = {}) ⇒ Object
43 44 45 46 47 |
# File 'lib/docxi/word/contents/paragraph.rb', line 43 def br(={}) br = Docxi::Word::Contents::Break.new() @content << br br end |
#image(image, options = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/docxi/word/contents/paragraph.rb', line 49 def image(image, ={}) img = Docxi::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/docxi/word/contents/paragraph.rb', line 19 def render(xml) xml['w'].p do xml['w'].pPr do xml['w'].jc( 'w:val' => [:align]) if [: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 |
#text(text, options = {}) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/docxi/word/contents/paragraph.rb', line 36 def text(text, ={}) = .merge() text = Docxi::Word::Contents::Text.new(text, ) @content << text text end |