Class: RubyFromExcel::FormulaCell

Inherits:
Cell
  • Object
show all
Defined in:
lib/cells/formula/formula_cell.rb

Instance Attribute Summary collapse

Attributes inherited from Cell

#dependencies, #reference, #worksheet, #xml_type, #xml_value

Instance Method Summary collapse

Methods inherited from Cell

#alter_other_cells_if_required, #can_be_replaced_with_value?, #initialize, #inspect, #test, #to_ruby, #to_s, #to_test, #tolerance_for, #value, #value_for_including

Constructor Details

This class inherits a constructor from RubyFromExcel::Cell

Instance Attribute Details

#astObject

Returns the value of attribute ast


3
4
5
# File 'lib/cells/formula/formula_cell.rb', line 3

def ast
  @ast
end

#original_formulaObject

Returns the value of attribute original_formula


3
4
5
# File 'lib/cells/formula/formula_cell.rb', line 3

def original_formula
  @original_formula
end

Instance Method Details

#debugObject


19
20
21
# File 'lib/cells/formula/formula_cell.rb', line 19

def debug
  RubyFromExcel.debug(:cells,"#{worksheet.name}.#{reference} -> #{original_formula.inspect} -> #{ast.inspect} -> #{xml_value} (#{xml_type}) -> #{value_for_including.inspect}")
end

#parse_xml(xml) ⇒ Object


5
6
7
8
9
# File 'lib/cells/formula/formula_cell.rb', line 5

def parse_xml(xml)
  super
  self.original_formula = xml.at_css("f").content
  self.ast = Formula.parse(original_formula)
end

#ruby_valueObject


15
16
17
# File 'lib/cells/formula/formula_cell.rb', line 15

def ruby_value
  "@#{reference.to_ruby} ||= #{ast.visit(FormulaBuilder.new(self))}"
end

#work_out_dependenciesObject


11
12
13
# File 'lib/cells/formula/formula_cell.rb', line 11

def work_out_dependencies
  self.dependencies ||= ast.visit(DependencyBuilder.new(self))
end