Brian Adkins wrote:
> Boris Blaadh <nejnejnej / gmail.com> writes:
> 
>> wordlist = string.split(' ')
>> # get rid of the last space
>> shorttext.chop!
>>
>> puts "#{shorttext}..."
> 
> It is nicer to break at word boundaries in some contexts. But if it's
> a single word (such as a long email address), then you'd still want to
> show something more than "...". Maybe you can add a check for that.
> 
> e.g. for string = 'john.smith / hisdomain.com', lead = 15

Hehe, ok:

if shorttext.empty?
  puts wordlist[0]
else
  puts "#{shorttext}..."
end
-- 
Posted via http://www.ruby-forum.com/.