Conversion on php library to ruby