From: "David A. Black" Date: 2004-12-14T01:05:45+09:00 Subject: Re: Help writing a each_unique method Hi -- On Tue, 14 Dec 2004, trans. (T. Onoma) wrote: > On Monday 13 December 2004 10:37 am, Robert Klemme wrote: > | What about > | > | class String > | def word_wrap!(n = 80) > | raise ArgumentError, "Wrap margin too low: #{n}" if n <= 2 > | gsub!( Regexp.new( "(.{1,#{n-1}}\\w)\\b\\s*" ), "\\1\n") > | end > | > | def word_wrap(n = 80) > | c = dup > | c.word_wrap! n > | c > | end > | end > > Thanks, robert. That's a nice basic approach, and for the lack of something > better I think I will used. But it would be nice to have something a little > more robust. Something that can determine when to divide and hyphenate a word > if it is just too long. Austin Ziegler is working on an interface to TeX's hyphenation facilities. I'm not sure where it stands, but we were talking about it last week and it sounded cool. David -- David A. Black dblack@wobblini.net