def ss
while true
print "|\r"
sleep 0.2
print "/\r"
sleep 0.2
print "-\r"
sleep 0.2
print "\\\r"
sleep 0.2
end
end
a = Thread.new { ss }
def spinner
chars = %w{ | / - \\ }
thread = Thread.new { yield }
while thread.alive?
$stdout.print chars[0]
sleep 0.5
$stdout.print "\b"
chars.push chars.shift
end
thread.join
end
spinner do
name=gets
puts name
end