Class: EquationBuilder
- Inherits:
-
Object
- Object
- EquationBuilder
- Defined in:
- lib/equation_builder.rb
Instance Method Summary collapse
-
#initialize(_numbers, _result, _operators) ⇒ EquationBuilder
constructor
A new instance of EquationBuilder.
- #solve ⇒ Object
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
#solve ⇒ Object
12 13 14 |
# File 'lib/equation_builder.rb', line 12 def solve solve_simple || solve_with_parentheses || nil end |