Justin Collins
11/11/2008 11:12:00 AM
[Note: parts of this message were removed to make it a legal post.]
David Trasbo wrote:
> Peter Szinek wrote:
>
>> I seriously doubt this is part of standard Ruby.
>>
>
> You're right, it's not a part of the Ruby standard library:
>
> Clifford Heath wrote:
>
>> There's no such method in Ruby. You might be thinking of the
>> truncate method that's part of ActionView's TextHelper module.
>>
>
> truncate is what it's called. I was actually searching for 'rails
> StringHelper'... :)
>
> Thanks for the replies!
>
Also:
a_long_string = "Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Pellentesque pulvinar turpis a nisi. Cras id elit. Aliquam vitae
pede nec lacus elementum lacinia. Ut aliquam ehicula sem."
limit = 86
a_long_string[0, limit] << "..." #=> "Lorem ipsum dolor sit amet,
consectetuer adipiscing elit. Pellentesque pulvinar turpis..."
-Justin