Move to ruby

That's translated from python code, don't blame me