Hi,

Is it possible to do this simpler ?

--8<--

# Check if your input is a number, quit if input is equal to 'quit'
class Testing_input_number
   def initialize
     answer = nil
     while a_number?(answer) != true
       answer = ask
       puts 'Please, a number.' unless a_number?(answer)
     end
     puts "OK, this is a number."
   end

   def ask
     print "Try?\s"
     number = gets.chomp
     bybye if number == 'quit'
     number
   end

   def a_number?(number)
     number.to_s == number.to_i.to_s
   end

   def bybye
     puts "Goodbye."
     exit
   end
end

player = Testing_input_number.new

-->8--

Thank you very much for the review.

/Nathan

Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>