From: William James Date: 2006-12-10T10:45:09+09:00 Subject: Re: text wrap ishamid wrote: > Hi, > > I have a ruby script that's doing what I need, and I would like to add > one feature. The script outputs a text file, and I would like Ruby to > take the final text file and wrap it at 67 characters, instead of doing > it manually in the editor. > > Is there an available method or something that I can invoke? If so, can > you give me an example of its use (I'm still very much a novice!) > > Best > Idris X = 10 # Width is 10 characters. str = "This\nis a test of the emergency broadcasting servicings I asseverate" p str.gsub(/\n/," ").scan(/\S.{0,#{X-2}}\S(?=\s|$)|\S+/)