class Ods::Row

Attributes

content[R]
sheet[R]

Public Class Methods

new(content, sheet) click to toggle source
# File lib/ods/row.rb, line 5
def initialize(content, sheet)
  @content = content
  @sheet = sheet
end

Public Instance Methods

[](index) click to toggle source
# File lib/ods/row.rb, line 10
def [](index)
  data[index]
end
cols() click to toggle source
# File lib/ods/row.rb, line 14
def cols
  return @cols if @cols
  @cols = []
  content.xpath('table:table-cell').each do |node|
    repeat = node['table:number-columns-repeated'] || 1
    a_cell = Cell.new(node, self)
    repeat.to_i.times do
      @cols << a_cell
    end
  end
  @cols
end
data() click to toggle source
# File lib/ods/row.rb, line 27
def data
  @data ||= begin
    values = if cols.last.value == ''
               cols.reject { |col| col == cols.last }
             else
               cols
             end.map(&:value)
    while values.length > 0 && values.last == ''
      values.pop
    end
    values
  end
end