Class: ExcelTemplating::Document::DataSourceRegistry::RegistryRenderer
- Inherits:
-
Object
- Object
- ExcelTemplating::Document::DataSourceRegistry::RegistryRenderer
- Defined in:
- lib/excel_templating/document/data_source_registry/registry_renderer.rb
Overview
In charge of rendering the data source registry to the excel document
Instance Method Summary collapse
-
#absolute_reference_for(source_symbol) ⇒ Hash
Gives back a hash of options which adds the validation options for the symbol.
-
#initialize(registry, data) ⇒ RegistryRenderer
constructor
A new instance of RegistryRenderer.
-
#write_sheet(workbook) ⇒ Object
Wrote this registry to the specified workbook.
Constructor Details
#initialize(registry, data) ⇒ RegistryRenderer
Returns a new instance of RegistryRenderer.
4 5 6 7 |
# File 'lib/excel_templating/document/data_source_registry/registry_renderer.rb', line 4 def initialize(registry, data) @registry = registry @data = data end |
Instance Method Details
#absolute_reference_for(source_symbol) ⇒ Hash
Returns Gives back a hash of options which adds the validation options for the symbol.
11 12 13 14 15 16 17 18 |
# File 'lib/excel_templating/document/data_source_registry/registry_renderer.rb', line 11 def absolute_reference_for(source_symbol) unless registry.has_registry?(source_symbol) raise ArgumentError, "#{source_symbol} is not a defined data_source. Defined data sources are " + "#{registry.supported_registries}" end registry_info = registry[source_symbol] (registry_info) end |
#write_sheet(workbook) ⇒ Object
Wrote this registry to the specified workbook. Uses the sheet name 'DataSource'
22 23 24 25 26 27 28 29 |
# File 'lib/excel_templating/document/data_source_registry/registry_renderer.rb', line 22 def write_sheet(workbook) return unless registry.any_data_sheet_symbols? data_sheet = workbook.add_worksheet(sheet_name) registry.each do |registry_info| write_data_source_to_sheet(data_sheet, registry_info) end end |