class ExtractArrayFormulaForCell
Constants
- FUNCTIONS_THAT_CAN_RETURN_ARRAYS
Attributes
column_offset[RW]
row_offset[RW]
Public Class Methods
new()
click to toggle source
# File src/rewrite/rewrite_array_formulae.rb, line 5 def initialize @fc = CachingFormulaParser.instance end
Public Instance Methods
map(ast)
click to toggle source
# File src/rewrite/rewrite_array_formulae.rb, line 9 def map(ast) case ast.first when :array; map_array(ast) when :function; map_function(ast) else return ast end end
map_array(ast)
click to toggle source
# File src/rewrite/rewrite_array_formulae.rb, line 17 def map_array(ast) if (@row_offset + 1) >= ast.length if ast.length == 2 @row_offset = 0 else return @fc.map([:error, :"#N/A"]) end end if (@column_offset + 1) >= ast[1].length if ast[1].length == 2 @column_offset = 0 else return @fc.map([:error, :"#N/A"]) end end ast[@row_offset+1][@column_offset+1] # plus ones to skip tthe [:array,[:row,"cell"]] symbols end
map_function(ast)
click to toggle source
# File src/rewrite/rewrite_array_formulae.rb, line 39 def map_function(ast) return ast unless FUNCTIONS_THAT_CAN_RETURN_ARRAYS.has_key?(ast[1]) [:function, :INDEX, ast.dup, @fc.map([:number, (@row_offset+1)]), @fc.map([:number, (column_offset+1)])] end