You don't need a class for this. Just use an until loop.

is_number = false

until is_number
  print "Enter a number: "
  raw_number = gets.chomp

  exit if raw_number == 'quit'

  is_number = number.to_s == number.to_i.to_s
end

puts "OK, this is a number."

On Tue, Nov 29, 2016 at 10:44 PM, Aleksey Ivanov <ialexxei / gmail.com> wrote:

> Hi.
>
> First thing that can be noticed is to replace
>
>     while smth != true do
>       ...
>     end
>
> with
>
>     until smth do
>       ...
>     end
>
>
> Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>
>
(supressed text/html)
Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>