Class: Simplemath

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

Class Method Summary collapse

Class Method Details

.operationObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gemacalc.rb', line 2

def self.operation
puts "Entre operator ( +|-|*|/ )"
operation = gets.chomp()

puts "Entre first number"
num1 = gets.chomp().to_i
puts "Entre second number"
num2 = gets.chomp().to_i

if num1.is_a?(Integer) && num2.is_a?(Integer)
    case operation
    when "+"
      puts(num1 + num2)
    when "-"
      puts(num1 - num2)
    when "*"
      puts(num1 * num2)
    when "/"
      puts(num1/num2)
    else
      puts 'Invalid operation, bye'
    end
  else
    puts 'Invalid numbers, bye'
  end
end