Module: Calculate
- Defined in:
- lib/gem_calculating.rb,
lib/gem_calculating/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.3"
Class Method Summary collapse
-
.add(num1, num2) ⇒ Object
Adds two numbers.
-
.divide(num1, num2) ⇒ Object
Divide two numbers.
-
.multiply(num1, num2) ⇒ Object
Multiply two numbers.
-
.subtract(num1, num2) ⇒ Object
Subtract two numbers.
Class Method Details
.add(num1, num2) ⇒ Object
Adds two numbers
6 7 8 9 10 11 12 13 |
# File 'lib/gem_calculating.rb', line 6 def self.add(num1, num2) if validate_numbers(num1, num2) == true return puts "Numbers is not valid" end num1 + num2 rescue StandardError nil end |
.divide(num1, num2) ⇒ Object
Divide two numbers
33 34 35 36 37 38 39 40 |
# File 'lib/gem_calculating.rb', line 33 def self.divide(num1, num2) if validate_numbers(num1, num2) == true return puts "Numbers is not valid" end num1 / num2 rescue StandardError nil end |
.multiply(num1, num2) ⇒ Object
Multiply two numbers
24 25 26 27 28 29 30 31 |
# File 'lib/gem_calculating.rb', line 24 def self.multiply(num1, num2) if validate_numbers(num1, num2) == true return puts "Numbers is not valid" end num1 * num2 rescue StandardError nil end |
.subtract(num1, num2) ⇒ Object
Subtract two numbers
15 16 17 18 19 20 21 22 |
# File 'lib/gem_calculating.rb', line 15 def self.subtract(num1, num2) if validate_numbers(num1, num2) == true return puts "Numbers is not valid" end num1 - num2 rescue StandardError nil end |