ruby: fix signed/unsigned comparisons