Method: Calculator.solve
- Defined in:
- lib/linmeric/Calculator.rb
.solve(exp) ⇒ Object
It solves the expression in string format
-
argument: expression to evaluate
-
returns: result of the expression;
nilif an error occourred
232 233 234 235 236 237 238 |
# File 'lib/linmeric/Calculator.rb', line 232 def self.solve(exp) lexer = Lexer.new evaluator = Evaluator.new stream = lexer.tokenize(exp) return nil if stream == nil return evaluator.evaluate(stream) end |