Ruby porting of the Python PYSTONE script