class Extract::Table

Attributes

cell_range[RW]
name[RW]
sheet_def[RW]

Public Instance Methods

cell_objs() click to toggle source
# File lib/extract/table.rb, line 37
def cell_objs
  cells.map { |c| Cell.new(:sheet_def => sheet_def, :cell => c) }
end
cell_row_hash() click to toggle source
# File lib/extract/table.rb, line 40
def cell_row_hash
  res = Hash.new { |h,k| h[k] = [] }
  cell_objs.each do |c|
    res[c.row] << c
  end
  res
end
cells() click to toggle source
# File lib/extract/table.rb, line 33
def cells
  Extract.expand_cells(cell_range)
end
field_names() click to toggle source
# File lib/extract/table.rb, line 48
def field_names
  k = cell_row_hash.keys.min
  cell_row_hash[k].map { |x| x.value }
end
rows() click to toggle source
# File lib/extract/table.rb, line 53
def rows
  cell_row_hash.values[1..-1].map { |a| Row.new(:table => self, :cells => a) }.select { |x| x.present? }
end
sql_statements() click to toggle source
# File lib/extract/table.rb, line 57
def sql_statements
  res = Extract::Export::Table.new(:name => name)
  rows.each do |row|
    res.rows << row.value_hash
  end
  res.sql_statements
end