def initialize(table, attributes = {})
@table = table
if attributes.has_key? 'format'
@format = attributes['format']
if !Table::DATA_FORMATS.include? @format
raise "Illegal table format: #@format"
end
else
@format = Table::DEFAULT_DATA_FORMAT
end
if @format == 'psv' && !attributes.has_key?('separator') && table.document.nested?
@delimiter = '!'
else
@delimiter = attributes.fetch('separator', Table::DEFAULT_DELIMITERS[@format])
end
@delimiter_re = /#{Regexp.escape @delimiter}/
@col_count = table.columns.empty? ? -1 : table.columns.size
@buffer = ''
@cell_specs = []
@cell_open = false
@active_rowspans = [0]
@col_visits = 0
@current_row = []
@linenum = -1
end