class InlineFormulae

Attributes

count_replaced[RW]
default_sheet_name[RW]
inline_ast[RW]
references[RW]

Public Class Methods

replace(*args) click to toggle source
# File src/simplify/inline_formulae.rb, line 110
def self.replace(*args)
  self.new.replace(*args)
end

Public Instance Methods

replace(input,output) click to toggle source
# File src/simplify/inline_formulae.rb, line 116
def replace(input,output)
  rewriter = InlineFormulaeAst.new(references, default_sheet_name, inline_ast)
  input.each_line do |line|
    # Looks to match lines with references
    if line =~ /\[:cell/
      ref, ast = line.split("\t")
      output.puts "#{ref}\t#{rewriter.map(eval(ast)).inspect}"
    else
      output.puts line
    end
  end
  @count_replaced = rewriter.count_replaced
end