Those two are the same result, modulo 232. In Ruby you could & 4294967295
to make the result the same as in Javascript.
To cover all the cases, you need to take into account that Javascript considers binary values to be signed 32-bit integers. Ruby on the other hand will produce unsigned 32-bit integers from the & 4294967295
operation.
So, in Javascript simply:
c = a ^ b
To get the same thing in Ruby:
c = (a ^ b) & 4294967295
c -= 4294967296 if c > 2147483647