Useful Ruby snippet of code