class RewriteCellReferencesToIncludeSheet

Attributes

worksheet[RW]

Public Class Methods

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

Public Instance Methods

rewrite(input,output) click to toggle source
# File src/rewrite/rewrite_cell_references_to_include_sheet.rb, line 70
def rewrite(input,output)
  mapper = RewriteCellReferencesToIncludeSheetAst.new
  mapper.worksheet = worksheet
  input.each_line do |line|
    if line =~ /(:area|:cell)/
      content = line.split("\t")
      ast = eval(content.pop)
      output.puts "#{content.join("\t")}\t#{mapper.map(ast).inspect}"
    else
      output.puts line
    end
  end
end