Add ref.; find index of an array element in Ruby