Forum: Ruby on Rails Word Wrapping

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A6af42e1a10fe69445480a6165e0187a?d=identicon&s=25 Prashant Katare (pkatare)
on 2009-06-09 11:20
Hi all,
        Is there any gem or plugin for "word wrapping".


The reason is I'm trying to generate a pdf from my application. There
are issues when I am trying to display long strings  with no spaces. A
word wrapper should solve the issue I guess.

Any help would be appreciated.

 Thanks
29ebf90af6107d2eb39b587c7972639c?d=identicon&s=25 Mukund (Guest)
on 2009-06-09 12:36
(Received via mailing list)
Why don't you write your own routine to wrap text?  Here is a simple
one.

def wrap_text(txt, col = 80)
  txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/,
    "\\1\\3\n")
end

Have a look at
http://blog.macromates.com/2006/wrapping-text-with...
for explanation.

On Jun 9, 2:20 pm, Prashant Katare <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.