Converting c to ruby