Class: Extract::Table
Instance Attribute Summary collapse
-
#cell_range ⇒ Object
Returns the value of attribute cell_range.
-
#name ⇒ Object
Returns the value of attribute name.
-
#sheet_def ⇒ Object
Returns the value of attribute sheet_def.
Instance Method Summary collapse
- #cell_objs ⇒ Object
- #cell_row_hash ⇒ Object
- #cells ⇒ Object
- #field_names ⇒ Object
- #rows ⇒ Object
- #sql_statements ⇒ Object
Instance Attribute Details
#cell_range ⇒ Object
Returns the value of attribute cell_range.
31 32 33 |
# File 'lib/extract/table.rb', line 31 def cell_range @cell_range end |
#name ⇒ Object
Returns the value of attribute name.
31 32 33 |
# File 'lib/extract/table.rb', line 31 def name @name end |
#sheet_def ⇒ Object
Returns the value of attribute sheet_def.
31 32 33 |
# File 'lib/extract/table.rb', line 31 def sheet_def @sheet_def end |
Instance Method Details
#cell_objs ⇒ Object
37 38 39 |
# 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 ⇒ Object
40 41 42 43 44 45 46 |
# 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 ⇒ Object
33 34 35 |
# File 'lib/extract/table.rb', line 33 def cells Extract.(cell_range) end |
#field_names ⇒ Object
48 49 50 51 |
# 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 ⇒ Object
53 54 55 |
# 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 ⇒ Object
57 58 59 60 61 62 63 |
# 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 |