Class: MathGenerator::Problem
- Inherits:
-
Object
- Object
- MathGenerator::Problem
- Defined in:
- lib/math_generator.rb
Constant Summary collapse
- OPERATIONS =
{ addition: "+", subtraction: "-", multiplication: "*", division: "/" }
Class Method Summary collapse
Class Method Details
.generate(operation, min = 1, max = 10, decimals = false, fractions = false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/math_generator.rb', line 16 def self.generate(operation, min = 1, max = 10, decimals = false, fractions = false) num1 = random_number(min, max, decimals, fractions) num2 = random_number(min, max, decimals, fractions) result = calculate_result(operation, num1, num2) { problem: format_problem(operation, num1, num2), result: result } end |