Class: Docxi::Word::Contents::Table::TableRow::TableCell
- Inherits:
-
Object
- Object
- Docxi::Word::Contents::Table::TableRow::TableCell
- Defined in:
- lib/docxi/word/contents/table.rb
Defined Under Namespace
Classes: Image, PageNumbers
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.
- #p(options = {}, &block) ⇒ Object
- #page_numbers ⇒ Object
- #render(xml) ⇒ Object
- #text(text, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TableCell
Returns a new instance of TableCell.
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/docxi/word/contents/table.rb', line 110 def initialize(={}) @options = @content = [] if block_given? yield self else end end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
109 110 111 |
# File 'lib/docxi/word/contents/table.rb', line 109 def content @content end |
#options ⇒ Object
Returns the value of attribute options.
109 110 111 |
# File 'lib/docxi/word/contents/table.rb', line 109 def @options end |
Instance Method Details
#image(image, options = {}) ⇒ Object
167 168 169 170 171 |
# File 'lib/docxi/word/contents/table.rb', line 167 def image(image, ={}) img = Image.new(image, ) @content << img img end |
#p(options = {}, &block) ⇒ Object
179 180 181 182 183 |
# File 'lib/docxi/word/contents/table.rb', line 179 def p(={}, &block) element = Docxi::Word::Contents::Paragraph.new(, &block) @content << element element end |
#page_numbers ⇒ Object
173 174 175 176 177 |
# File 'lib/docxi/word/contents/table.rb', line 173 def page_numbers numbers = PageNumbers.new @content << numbers numbers end |
#render(xml) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/docxi/word/contents/table.rb', line 121 def render(xml) if [:fill].blank? [:fill] = 'FFFFFF' end 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 |