title: Check if integer is positive in ruby
body: <p>I'm trying to make users input a positive integer(>=1). If the user inputs a negative integer or 0, the program gonna notice and say you didn't put a valid integer, please try again. my program works so far until I try to input a string. My program break after I input a string. Does anybody know how to fix this?</p>
  
  <p>I tried elsif !barsofsoap.match (/\A[-+]?[0-9]*.?[0-9]+\Z/)
      puts "You didn't enter an integer, please put a positive integer", but it didn't work</p>
  
  <pre><code>loop do
    puts "How many soaps are you looking to purchase? (Please put an integer)"
    x = gets.chomp
    barsofsoap = Integer(x) rescue false
  
    if barsofsoap &gt;= 1
      break
    else
      puts "You didn't put an integer, please put an integer and try again."
    end
  end
  </code></pre>
  
  <p>I hope the program will not break if the user inputs a string.</p>