I recommended reading about #tap; how one could use a Hash to remove some duplication.
I also thought it could be a good occasion to talk about how Ruby String’s are mutable
but in some time string literals will be immutable
. The keyword here is literals.

In such case we would need to go with a less elegant solution probably:

string=String.newstring<<'Pling'ifnum%3==0

because

s=String.news.frozen?# => falses<<"asd"# => "asd"

So just be aware that in upcoming Ruby versions s = "" and
s = String.new might not be equal. And in the case when you
are building a new string via multiple transformations or
concatenations the 2nd version might be preffered.

I wonder if some time later ruby (4 ?) will make all Strings
immutable (not only those created via literals) and introduce
StringBuilder class like .Net or Java has?