Class: Igros::CLI
- Inherits:
-
Object
- Object
- Igros::CLI
- Defined in:
- lib/igros/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #goodbye ⇒ Object
- #greeting ⇒ Object
- #looper ⇒ Object
- #my_number3 ⇒ Object
- #my_number5 ⇒ Object
- #my_number7 ⇒ Object
- #sequence ⇒ Object
- #your_number ⇒ Object
Instance Method Details
#call ⇒ Object
3 4 5 6 7 |
# File 'lib/igros/cli.rb', line 3 def call greeting sequence goodbye end |
#goodbye ⇒ Object
97 98 99 |
# File 'lib/igros/cli.rb', line 97 def goodbye puts "See you another time!" end |
#greeting ⇒ Object
9 10 11 |
# File 'lib/igros/cli.rb', line 9 def greeting puts "Welcome to my math gem!" end |
#looper ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/igros/cli.rb', line 83 def looper puts "Wanna try again? (y/n)" input = gets.strip.downcase case input when "y" puts "Awesome!" sequence when "n" puts "That's ok, we had fun." else puts "I didn't catch that, please type 'y' for Yes or 'n' for No." looper end def goodbye puts "See you another time!" end end |
#my_number3 ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/igros/cli.rb', line 23 def my_number3 puts "Please divide your number into three and submit the remainder." begin @x3 = Integer(gets.chomp) rescue puts "Nice try! That's not even a number..." retry end unless @x3 < 3 puts "Are you sure? it sounds like your math is off." my_number3 else puts "The remainder for 3 was #{@x3}." end end |
#my_number5 ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/igros/cli.rb', line 39 def my_number5 puts "\nNow, please divide your number into five and submit the remainder." begin @x5 = Integer(gets.chomp) rescue puts "Nice try! That's not even a number..." retry end unless @x5 < 5 puts "Are you sure? it sounds like your math is off." my_number5 else puts "The remainder for 5 was #{@x5}." end end |
#my_number7 ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/igros/cli.rb', line 55 def my_number7 puts "\nAlmost done! Now please divide your number into seven and submit the remainder." begin @x7 = Integer(gets.chomp) rescue puts "Nice try! That's not even a number..." retry end unless @x7 < 7 puts "Are you sure? it sounds like your math is off." my_number7 else puts "The remainder for 7 was #{@x7}." end end |
#sequence ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/igros/cli.rb', line 13 def sequence puts "Please chose a number between 1 and 100. When you are ready hit Enter." gets.strip my_number3 my_number5 my_number7 your_number looper end |
#your_number ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/igros/cli.rb', line 71 def your_number @number = (@x3 * 70) + (@x5 * 21) + (@x7 * 15) until @number <= 105 @number -= 105 end if @number > 100 puts "\nYou think you can outsmart me! Your number was #{@number}" else puts "\nAwesome! Your number was #{@number}. Wasn't that cool?" end end |