I personally find % cleaner than printf:

puts "%03d" % val