I want to truncate a string as follows:
input:
string = \"abcd asfsa sadfsaf safsdaf aaaaaaaaaa aaaaaaaaaa ffffdffffdffffdffffddd\"
This may not be the exact solution to your problem, but I think it will help put you in the right direction, with a pretty clean way of doing things.
If you want "Hello, World!" to be limited to the first five letters, you can do:
str = "Hello, World!"
str[0...5] # => "Hello"
If you want an ellipses, just interpolate it:
"#{str[0...5]}..." #=> "Hello..."