The line (result = uuidgen.strip rescue nil).empty? does not work since empty? is not a method in Nil class. You could use nil? or blank? but why even call uuidgen; it only needs to be unique on the current server therefore using "#{Time.now.to_f}-#{Thread.current.hash}-#{hash}" is more than adequate.
Note that I propose Time.now.to_f rather than to_i
Thanks