Class: Docxi::Word::Contents::Text
- Inherits:
-
Object
- Object
- Docxi::Word::Contents::Text
- Defined in:
- lib/docxi/word/contents/text.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text, options = {}) ⇒ Text
constructor
A new instance of Text.
- #render(xml) ⇒ Object
Constructor Details
#initialize(text, options = {}) ⇒ Text
Returns a new instance of Text.
8 9 10 11 |
# File 'lib/docxi/word/contents/text.rb', line 8 def initialize(text, ={}) @text = text @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/docxi/word/contents/text.rb', line 7 def @options end |
#text ⇒ Object
Returns the value of attribute text.
7 8 9 |
# File 'lib/docxi/word/contents/text.rb', line 7 def text @text end |
Instance Method Details
#render(xml) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/docxi/word/contents/text.rb', line 13 def render(xml) if !@text.nil? xml['w'].r do xml['w'].rPr do xml['w'].rFonts( 'w:cs'=> @options[:font], 'w:ascii'=> @options[:font], 'w:hAnsi' => @options[:font] ) if @options[:font] xml['w'].b if @options[:bold] xml['w'].i if @options[:italic] xml['w'].u( 'w:val' => "single" ) if [:underline] xml['w'].color( 'w:val' => @options[:color] ) if @options[:color] xml['w'].sz( 'w:val' => @options[:size].to_i * 2 ) if @options[:size] xml['w'].shd( 'w:val' => 'clear','w:fill' => @options[:fill] ) if @options[:fill] end if @options[:space] xml['w'].t( @text, 'xml:space' => "preserve" ) else xml['w'].t @text end end if [:br] br = Docxi::Word::Contents::Break.new br.render(xml) end end end |