Ruby: Splitting strings and using each