class RewriteArrayFormulae

Public Class Methods

rewrite(*args) click to toggle source
# File src/rewrite/rewrite_array_formulae.rb, line 47
def self.rewrite(*args)
  new.rewrite(*args)
end

Public Instance Methods

array_formula(sheet, array_range, array_ast) click to toggle source
# File src/rewrite/rewrite_array_formulae.rb, line 62
def array_formula(sheet, array_range, array_ast)
  array_range = "#{array_range}:#{array_range}" unless array_range.include?(':')
  array_range = Area.for(array_range)
  array_range.calculate_excel_variables
  start_reference = array_range.excel_start
  mapper = ExtractArrayFormulaForCell.new
  
  # Then we rewrite each of the subsidiaries
  array_range.offsets.each do |row,column|
    mapper.row_offset = row
    mapper.column_offset = column
    ref = start_reference.offset(row,column)
    @output[[sheet.to_sym, ref.to_sym]] = mapper.map(array_ast)
  end
end
rewrite(input) click to toggle source
# File src/rewrite/rewrite_array_formulae.rb, line 51
def rewrite(input)
  @output = {}
  input.each do |ref, details|
    sheet = ref[0]
    array_range = details[0]
    ast = details[1]
    array_formula(sheet, array_range, ast)
  end
  @output
end