lib/wiz_rtf/cell.rb in wiz_rtf-0.5.0 vs lib/wiz_rtf/cell.rb in wiz_rtf-0.5.5
- old
+ new
@@ -7,18 +7,18 @@
module WizRtf
class Cell
attr_accessor :colspan, :rowspan, :content, :v_merge, :right_width
def initialize(cell)
- unless cell.is_a?(Hash)
- @colspan = 1
- @rowspan = 1
- @content = cell
- else
+ if cell.is_a?(Hash)
@colspan = cell[:colspan] || 1
@rowspan = cell[:rowspan] || 1
@content = cell[:content] || ''
+ else
+ @colspan = 1
+ @rowspan = 1
+ @content = cell
end
end
def render(io)
io.cmd :celld
@@ -34,10 +34,17 @@
io.cmd :clbrdrr
io.cmd :brdrs
io.cmd :brdrw10
io.cmd v_merge if v_merge
io.cmd :cellx, right_width
- io.txt content
+ contents = [@content] unless @content.is_a?(Array)
+ contents.each do |c|
+ if c.respond_to?(:render)
+ c.render(io)
+ else
+ io.txt c
+ end
+ end
io.cmd :cell
end
end
end