If you want to do string padding, which it seems you're doing here, why not use the sprint
notation?
out.puts "| %-70s|" % description.to_s
This uses the String#%
method.
The %-70s
means pad string to 70 spaces, left aligned. Without -
it is right aligned.
Any values that are too long will overflow this spot. To handle that:
out.puts "| %-70s|" % description.to_s[0,70]
That should limit it to the first 70 characters. Within the Rails environment there's a method called truncate
that can add on an ellipsis to show truncation occurred.