Class: EquationBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/equation_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(_numbers, _result, _operators) ⇒ EquationBuilder

Returns a new instance of EquationBuilder.



3
4
5
6
7
8
9
# File 'lib/equation_builder.rb', line 3

def initialize _numbers, _result, _operators
  @numbers = _numbers
  @result = _result
  @operators = Array(_operators)

  @matcher = proc { |numbers, operators, result| numbers.zip(operators).flatten.join if eval(make_float(numbers).zip(operators).flatten.join) == result }
end

Instance Method Details

#solveObject



12
13
14
# File 'lib/equation_builder.rb', line 12

def solve
  solve_simple || solve_with_parentheses || nil
end