Class: Docxi::Word::Contents::Table::TableRow

Inherits:
Object
  • Object
show all
Defined in:
lib/docxi/word/contents/table.rb

Defined Under Namespace

Classes: TableCell

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ TableRow

Returns a new instance of TableRow.



60
61
62
63
64
65
66
67
68
69
# File 'lib/docxi/word/contents/table.rb', line 60

def initialize(options={})
  @options = options
  @cells = []

  if block_given?
    yield self
  else

  end
end

Instance Attribute Details

#cellsObject

Returns the value of attribute cells.



59
60
61
# File 'lib/docxi/word/contents/table.rb', line 59

def cells
  @cells
end

#optionsObject

Returns the value of attribute options.



59
60
61
# File 'lib/docxi/word/contents/table.rb', line 59

def options
  @options
end

Instance Method Details

#render(xml) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/docxi/word/contents/table.rb', line 82

def render(xml)
  xml['w'].tr do
    @cells.each do |cell|
      cell.render(xml)
    end
  end
end

#tc(options = {}, &block) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/docxi/word/contents/table.rb', line 71

def tc(options={}, &block)
  if @options[:columns_width]
    width = @options[:columns_width][@cells.size]
    options[:width] ||= width if width
  end
  options = @options.merge(options)
  cell = TableCell.new(options, &block)
  @cells << cell
  cell
end