Class: Docxer::Word::Contents::Table::TableRow::TableCell
- Inherits:
-
Object
- Object
- Docxer::Word::Contents::Table::TableRow::TableCell
- Defined in:
- lib/docxer/word/contents/table.rb
Defined Under Namespace
Classes: Image
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #image(image, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ TableCell
constructor
A new instance of TableCell.
- #render(xml) ⇒ Object
- #text(text, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TableCell
Returns a new instance of TableCell.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/docxer/word/contents/table.rb', line 93 def initialize(={}) @options = @content = [] if block_given? yield self else end end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
92 93 94 |
# File 'lib/docxer/word/contents/table.rb', line 92 def content @content end |
#options ⇒ Object
Returns the value of attribute options.
92 93 94 |
# File 'lib/docxer/word/contents/table.rb', line 92 def @options end |
Instance Method Details
#image(image, options = {}) ⇒ Object
147 148 149 150 151 |
# File 'lib/docxer/word/contents/table.rb', line 147 def image(image, ={}) img = Image.new(image, ) @content << img img end |
#render(xml) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/docxer/word/contents/table.rb', line 104 def render(xml) xml['w'].tc do xml['w'].tcPr do xml['w'].tcW( 'w:w' => ( [:width].to_i * 14.92 ).to_i, 'w:type' => "dxa" ) if [:width] xml['w'].shd( 'w:val' => "clear", 'w:color' => "auto", 'w:fill' => [:fill] ) if [:fill] if [:borders] xml['w'].tcBorders do [:borders].each do |k, v| if v.nil? xml['w'].send(k, 'w:val' => "nil" ) else xml['w'].send(k, 'w:val' => "single", 'w:sz' => v, 'w:space' => "0", 'w:color' => "auto" ) end end end end if [:merged] xml['w'].vMerge else xml['w'].vAlign( 'w:val' => [:valign] ) if [:valign] xml['w'].gridSpan( 'w:val' => [:colspan] ) if [:colspan] xml['w'].vMerge( 'w:val' => "restart" ) if [:rowspan] end end if [:merged] xml['w'].p else @content.each do |element| element.render(xml) end end end end |