From ff3d4ee51c9300159d6e83761a50cca394d111ad Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 30 Sep 2014 08:55:21 -0400 Subject: [PATCH] Cache some sheet info for a small speedup while searching. --- lib/svggvs/data_source.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/svggvs/data_source.rb b/lib/svggvs/data_source.rb index 98e1d72..3c1c57c 100644 --- a/lib/svggvs/data_source.rb +++ b/lib/svggvs/data_source.rb @@ -13,7 +13,7 @@ module SVGGVS def settings settings = {} - doc.each_with_pagename do |name, sheet| + sheets.each do |name, sheet| if name['SVGGVS Settings'] sheet.each do |setting, value| settings[setting.spunderscore.to_sym] = value @@ -24,8 +24,20 @@ module SVGGVS settings end - def each_card(card_sheet_identifier) + def sheets + return @sheets if @sheets + + @sheets = [] + doc.each_with_pagename do |name, sheet| + @sheets << [ name, sheet.dup ] + end + + @sheets + end + + def each_card(card_sheet_identifier) + sheets.each do |name, sheet| if name[card_sheet_identifier] headers = sheet.row(1)