Class: Docxi::Word::Contents::Paragraph
- Inherits:
-
Object
- Object
- Docxi::Word::Contents::Paragraph
- Defined in:
- lib/docxi/word/contents/paragraph.rb
Defined Under Namespace
Classes: Hyperlink
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#id ⇒ Object
Returns the value of attribute id.
-
#options ⇒ Object
Returns the value of attribute options.
-
#relationships ⇒ Object
Returns the value of attribute relationships.
Instance Method Summary collapse
- #br(options = {}) ⇒ Object
- #content_type ⇒ Object
- #frame(options = {}, &block) ⇒ Object
- #hyperlink(text, link, id) ⇒ Object
- #image(image, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Paragraph
constructor
A new instance of Paragraph.
- #render(xml) ⇒ Object
- #tab(options = {}) ⇒ Object
- #target ⇒ 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 18 |
# File 'lib/docxi/word/contents/paragraph.rb', line 8 def initialize(={}) @content = [] @options = @relationships = [] 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 |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/docxi/word/contents/paragraph.rb', line 7 def id @id end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/docxi/word/contents/paragraph.rb', line 7 def @options end |
#relationships ⇒ Object
Returns the value of attribute relationships.
7 8 9 |
# File 'lib/docxi/word/contents/paragraph.rb', line 7 def relationships @relationships end |
Instance Method Details
#br(options = {}) ⇒ Object
104 105 106 107 108 |
# File 'lib/docxi/word/contents/paragraph.rb', line 104 def br(={}) br = Docxi::Word::Contents::Break.new() @content << br br end |
#content_type ⇒ Object
20 21 22 |
# File 'lib/docxi/word/contents/paragraph.rb', line 20 def content_type "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" end |
#frame(options = {}, &block) ⇒ Object
98 99 100 101 102 |
# File 'lib/docxi/word/contents/paragraph.rb', line 98 def frame(={}, &block) element = Docxi::Word::Contents::Frame.new(, &block) @content << element element end |
#hyperlink(text, link, id) ⇒ Object
29 30 31 32 |
# File 'lib/docxi/word/contents/paragraph.rb', line 29 def hyperlink(text,link,id) text = Hyperlink.new(text, link, id) @content << text end |
#image(image, options = {}) ⇒ Object
116 117 118 119 120 |
# File 'lib/docxi/word/contents/paragraph.rb', line 116 def image(image, ={}) img = Docxi::Word::Contents::Image.new(image, ) @content << img img end |
#render(xml) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/docxi/word/contents/paragraph.rb', line 64 def render(xml) xml['w'].p do xml['w'].pPr do xml['w'].jc( 'w:val' => @options[:align]) if @options[:align] xml['w'].shd( 'w:val' => 'clear','w:fill' => @options[:fill] ) if @options[:fill] xml['w'].ind( 'w:left' => @options[:left], 'w:right' => @options[:right] ) if @options[:left] and @options[:right] if [:ul] xml['w'].numPr do xml['w'].ilvl( 'w:val' => 0 ) xml['w'].numId( 'w:val' => 1 ) end end if [:bottom] xml['w'].pBdr do xml['w'].top( 'w:val' => "nil") xml['w'].left('w:val' => "nil") xml['w'].bottom('w:val'=>"single", 'w:sz'=>"4", 'w:space'=>"1", 'w:color'=>"000000") xml['w'].right('w:val'=>"nil") end end end @content.each do |element| element.render(xml) end end end |
#tab(options = {}) ⇒ Object
110 111 112 113 114 |
# File 'lib/docxi/word/contents/paragraph.rb', line 110 def tab(={}) tab = Docxi::Word::Contents::Tab.new() @content << tab tab end |
#target ⇒ Object
24 25 26 |
# File 'lib/docxi/word/contents/paragraph.rb', line 24 def target "document.xml" end |