Ruby: convert hex numbers to binary file

#!/usr/bin/env ruby

hex =  File.binread('060645cc5ebdf80e84ebc91547641b49')
out = hex.scan(/../).map{ |x| x.to_i(16).chr }.join
File.binwrite("out.bin", out)