Class: ExcelTemplating::Document::DataSourceRegistry::RegistryRenderer

Inherits:
Object
  • Object
show all
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

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.

Parameters:

  • source_symbol (Symbol)

Returns:

  • (Hash)

    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]
  validation_options_for(registry_info)
end

#write_sheet(workbook) ⇒ Object

Wrote this registry to the specified workbook. Uses the sheet name 'DataSource'

Parameters:

  • workbook (ExcelAbstraction::Workbook)


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