From: Boris Blaadh Date: 2008-11-12T20:38:52+09:00 Subject: Re: What is that method called? Brian Adkins wrote: > Boris Blaadh 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/.