Actually, this might be a bit cleaner:

def randomFileNameSuffix (numberOfRandomchars)
  s = ""
  numberOfRandomchars.times { s << (65 + rand(26))  }
  s
end

puts "foo_" + randomFileNameSuffix(7) + ".txt"

=> foo_OLNMGZZ.txt

Note:  the 65 added is the numeric value of "A".  rand(26) gives 0..25. 
So, we add that to a capital "A" to get the random letter.

It is rather simple but that is not always a defect.
-- 
Posted via http://www.ruby-forum.com/.