Class: Rdb2spreadsheet::DataAdapter
- Inherits:
-
Object
- Object
- Rdb2spreadsheet::DataAdapter
- Defined in:
- lib/rdb2spreadsheet/data_adapter.rb
Instance Attribute Summary collapse
-
#rdb_client ⇒ Object
readonly
Returns the value of attribute rdb_client.
-
#spreadsheet_client ⇒ Object
readonly
Returns the value of attribute spreadsheet_client.
Instance Method Summary collapse
- #import_all(book_key, sqls) ⇒ Object
-
#initialize(db_configs, spreadsheet_configs) ⇒ DataAdapter
constructor
A new instance of DataAdapter.
Constructor Details
#initialize(db_configs, spreadsheet_configs) ⇒ DataAdapter
Returns a new instance of DataAdapter.
7 8 9 10 |
# File 'lib/rdb2spreadsheet/data_adapter.rb', line 7 def initialize(db_configs, spreadsheet_configs) @rdb_client = RdbClient.new(db_configs) @spreadsheet_client = SpreadsheetClient.new(spreadsheet_configs) end |
Instance Attribute Details
#rdb_client ⇒ Object (readonly)
Returns the value of attribute rdb_client.
5 6 7 |
# File 'lib/rdb2spreadsheet/data_adapter.rb', line 5 def rdb_client @rdb_client end |
#spreadsheet_client ⇒ Object (readonly)
Returns the value of attribute spreadsheet_client.
5 6 7 |
# File 'lib/rdb2spreadsheet/data_adapter.rb', line 5 def spreadsheet_client @spreadsheet_client end |
Instance Method Details
#import_all(book_key, sqls) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rdb2spreadsheet/data_adapter.rb', line 12 def import_all(book_key, sqls) @spreadsheet_client.open_book_by_key(book_key) sqls.each do |worksheet, sql| puts worksheet + ' updating' headers, records = @rdb_client.select(sql) next if headers.nil? || records.nil? @spreadsheet_client.update_worksheet(worksheet, headers, records) puts worksheet + ' updated' end end |