ruby: Use Kernel#loop instead of `while`