Class: WinExcelDb::MetaRow
- Inherits:
-
Object
- Object
- WinExcelDb::MetaRow
- Defined in:
- lib/win_excel_db/meta_row.rb
Instance Attribute Summary collapse
-
#data_rows ⇒ Object
readonly
Container for DataRows from different tables in one virtual => MetaRow.
Instance Method Summary collapse
- #add(row) ⇒ Object
-
#delete_row(name) ⇒ Object
a data row is deleted, not a meta row!.
-
#include?(field) ⇒ Boolean
test if MetaRow has a DataRow of a specific row_sheet.
-
#initialize(data_row = nil) ⇒ MetaRow
constructor
A new instance of MetaRow.
-
#read(field) ⇒ Object
Returns empty string in case a DataRow is not part of this MetaRow.
- #read_formula(field) ⇒ Object
- #write(field, value) ⇒ Object
- #write_formula(field, value) ⇒ Object
Constructor Details
#initialize(data_row = nil) ⇒ MetaRow
Returns a new instance of MetaRow.
9 10 11 12 13 14 15 16 |
# File 'lib/win_excel_db/meta_row.rb', line 9 def initialize(data_row=nil) @fields=Hash.new @sheets=Hash.new @data_rows=Hash.new if data_row then add(data_row) end end |
Instance Attribute Details
#data_rows ⇒ Object (readonly)
Container for DataRows from different tables in one virtual => MetaRow
7 8 9 |
# File 'lib/win_excel_db/meta_row.rb', line 7 def data_rows @data_rows end |
Instance Method Details
#add(row) ⇒ Object
18 19 20 |
# File 'lib/win_excel_db/meta_row.rb', line 18 def add(row) @data_rows[row.name]=row end |
#delete_row(name) ⇒ Object
a data row is deleted, not a meta row!
59 60 61 62 63 64 65 |
# File 'lib/win_excel_db/meta_row.rb', line 59 def delete_row(name) #a data row is deleted, not a meta row! data_row=@data_rows[name] if data_row then @data_rows.delete(name) data_row.delete end end |
#include?(field) ⇒ Boolean
test if MetaRow has a DataRow of a specific row_sheet. Checks only the sheet part, not the field.
41 42 43 |
# File 'lib/win_excel_db/meta_row.rb', line 41 def include?(field) return @data_rows[get_sheet(field)] end |
#read(field) ⇒ Object
Returns empty string in case a DataRow is not part of this MetaRow
24 25 26 27 28 29 30 |
# File 'lib/win_excel_db/meta_row.rb', line 24 def read(field) if @data_rows[get_sheet(field)] then @data_rows[get_sheet(field)].read(get_field(field)) else return "" end end |
#read_formula(field) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/win_excel_db/meta_row.rb', line 32 def read_formula(field) if @data_rows[get_sheet(field)] then @data_rows[get_sheet(field)].read_formula(get_field(field)) else return "" end end |
#write(field, value) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/win_excel_db/meta_row.rb', line 45 def write(field, value) cur_sheet=get_sheet(field) cur_field=get_field(field) raise "Write error! MetaRow has no DataRow of a Sheet \"#{cur_sheet}\" but is asked to write to its field \"#{cur_field}\"" if !@data_rows[cur_sheet] @data_rows[cur_sheet].write(cur_field, value) end |
#write_formula(field, value) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/win_excel_db/meta_row.rb', line 52 def write_formula(field, value) cur_sheet=get_sheet(field) cur_field=get_field(field) raise "Write error! MetaRow has no DataRow of a Sheet \"#{cur_sheet}\" but is asked to write to its field \"#{cur_field}\"" if !@data_rows[cur_sheet] @data_rows[cur_sheet].write_formula(cur_field, value) end |