class RewriteCellReferencesToIncludeSheetAst
Attributes
worksheet[RW]
Public Class Methods
new()
click to toggle source
# File src/rewrite/rewrite_cell_references_to_include_sheet.rb, line 7 def initialize @fp = CachingFormulaParser.instance end
Public Instance Methods
area(ast)
click to toggle source
# File src/rewrite/rewrite_cell_references_to_include_sheet.rb, line 44 def area(ast) ast[1] = ast[1].to_s.gsub('$','').to_sym ast[2] = ast[2].to_s.gsub('$','').to_sym @fp.map([:sheet_reference, worksheet, ast.dup]) end
cell(ast)
click to toggle source
# File src/rewrite/rewrite_cell_references_to_include_sheet.rb, line 39 def cell(ast) ast[1] = ast[1].to_s.gsub('$','').to_sym @fp.map([:sheet_reference, worksheet, ast.dup]) end
do_map(ast)
click to toggle source
# File src/rewrite/rewrite_cell_references_to_include_sheet.rb, line 18 def do_map(ast) return ast unless ast.is_a?(Array) return cell(ast) if ast[0] == :cell return area(ast) if ast[0] == :area return sheet_reference(ast) if ast[0] == :sheet_reference ast.each.with_index do |a,i| next unless a.is_a?(Array) case a[0] when :cell ast[i] = cell(a) when :area ast[i] = area(a) when :sheet_reference ast[i] = sheet_reference(a) else do_map(a) end end ast end
map(ast)
click to toggle source
FIXME: UGh.
# File src/rewrite/rewrite_cell_references_to_include_sheet.rb, line 12 def map(ast) r = do_map(ast) ast.replace(r) unless r.object_id == ast.object_id ast end
sheet_reference(ast)
click to toggle source
# File src/rewrite/rewrite_cell_references_to_include_sheet.rb, line 50 def sheet_reference(ast) if ast[2][0] == :cell ast[2][1] = ast[2][1].to_s.gsub('$','').to_sym elsif ast[2][1] == :area ast[2][1] = ast[2][1].to_s.gsub('$','').to_sym ast[2][2] = ast[2][2].to_s.gsub('$','').to_sym end @fp.map(ast) end