XOR gets produces 1 when the two bits are different i.e (1,0) and (0,1),
And XOR in Ruby is '^',
To get the result as string, use the formatter '%b',
And then count the ones in the resulted string,
That's your hamming distance!
("%b" % (x^y)).count('1')