From: Jim Menard Date: 2008-12-03T02:15:23+09:00 Subject: Re: Substring with "..." On Tue, Dec 2, 2008 at 12:00 PM, Jose Antonio Parra wrote: > Hi! > > I want to know what is the method to take a string and return a > substring with 20 characters and "..." if the length of the string is > greater, or the complete string if it's shorter than 20 characters. > Thanks all. Is this a school assignment? What have you tried so far? You can break this problem down into two parts: grabbing the first 20 characters, and adding the "...". For bonus points, you should handle the case where the string is already less than 20 characters long, which would require that you find out how long the string is in the first place. You should look at the documentation for the String class, which will list all of the methods available to you. You can see the list by typing "ri String" in the shell or visiting http://www.ruby-doc.org/core/classes/String.html Jim -- Jim Menard, jimm@io.com, jim.menard@gmail.com http://www.io.com/~jimm/