Class: WizRtf::Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/wiz_rtf/cell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cell) ⇒ Cell



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/wiz_rtf/cell.rb', line 11

def initialize(cell)
  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

Instance Attribute Details

#colspanObject

Returns the value of attribute colspan.



9
10
11
# File 'lib/wiz_rtf/cell.rb', line 9

def colspan
  @colspan
end

#contentObject

Returns the value of attribute content.



9
10
11
# File 'lib/wiz_rtf/cell.rb', line 9

def content
  @content
end

#right_widthObject

Returns the value of attribute right_width.



9
10
11
# File 'lib/wiz_rtf/cell.rb', line 9

def right_width
  @right_width
end

#rowspanObject

Returns the value of attribute rowspan.



9
10
11
# File 'lib/wiz_rtf/cell.rb', line 9

def rowspan
  @rowspan
end

#v_mergeObject

Returns the value of attribute v_merge.



9
10
11
# File 'lib/wiz_rtf/cell.rb', line 9

def v_merge
  @v_merge
end

Instance Method Details

#render(io) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/wiz_rtf/cell.rb', line 23

def render(io)
  io.cmd :celld
  io.cmd :clbrdrt
  io.cmd :brdrs
  io.cmd :brdrw10
  io.cmd :clbrdrl
  io.cmd :brdrs
  io.cmd :brdrw10
  io.cmd :clbrdrb
  io.cmd :brdrs
  io.cmd :brdrw10
  io.cmd :clbrdrr
  io.cmd :brdrs
  io.cmd :brdrw10
  io.cmd  v_merge if v_merge
  io.cmd :cellx, right_width
  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