Class: SVGGVS::DataSource
- Inherits:
-
Object
- Object
- SVGGVS::DataSource
- Defined in:
- lib/svggvs/data_source.rb
Instance Method Summary collapse
- #doc ⇒ Object
- #each_card(card_sheet_identifier) ⇒ Object
-
#initialize(file, options = {}) ⇒ DataSource
constructor
A new instance of DataSource.
- #settings ⇒ Object
Constructor Details
#initialize(file, options = {}) ⇒ DataSource
Returns a new instance of DataSource.
5 6 7 |
# File 'lib/svggvs/data_source.rb', line 5 def initialize(file, = {}) @file, @options = [ file, ].flatten.compact end |
Instance Method Details
#doc ⇒ Object
9 10 11 |
# File 'lib/svggvs/data_source.rb', line 9 def doc @doc ||= Roo::Spreadsheet.open(@file, @options) end |
#each_card(card_sheet_identifier) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/svggvs/data_source.rb', line 27 def each_card(card_sheet_identifier) doc.each_with_pagename do |name, sheet| if name[card_sheet_identifier] headers = sheet.row(1) (sheet.first_row + 1).upto(sheet.last_row) do |index| card_data = { :active_layers => [], :replacements => {} } headers.zip(sheet.row(index)).each do |header, cell| if header['Active Layer'] card_data[:active_layers] += cell.split(';') else card_data[:replacements][header] = cell end end yield card_data end end end end |
#settings ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/svggvs/data_source.rb', line 13 def settings settings = {} doc.each_with_pagename do |name, sheet| if name['SVGGVS Settings'] sheet.each do |setting, value| settings[setting.spunderscore.to_sym] = value end end end settings end |