Method: Extract::MathCalc#parse_eval

Defined in:
lib/extract/math_calc.rb

#parse_eval(input) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/extract/math_calc.rb', line 89

def parse_eval(input)
  raw_input = input
  #raise input.map { |x| x.text_value }.inspect
  input = input.map { |x| MathWrapper.new(:str => (x.respond_to?(:excel_value) ? x.excel_value : x.text_value)) }
  #input = input.split(" ") if input.kind_of?(String)
  res = shunting_yard(input)
  #puts "before rpn #{res.inspect}"
  begin
    res = rpn(res)
  rescue => exp
    puts raw_input.map { |x| x.text_value }.inspect
    puts res.inspect
    raise exp
  end
end