Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Change Proposal for "String#word_wrap" (Ruby on Rails - ActionView::Helpers::TextHelper) (http://www.velocityreviews.com/forums/t837854-change-proposal-for-string-word_wrap-ruby-on-rails-actionview-helpers-texthelper.html)

Wolfgang Nádasi-Donner 02-04-2007 12:33 PM

Change Proposal for "String#word_wrap" (Ruby on Rails - ActionView::Helpers::TextHelper)
 
Hi!

Hope this is the right place (I'm not a Ruby on Rails user).

The Method ist defined as
(http://api.rubyonrails.org/classes/A...html#M000616):

def word_wrap(text, line_width = 80)
text.gsub(/\n/, "\n\n").gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip
end

The sense of the part 'gsub(/\n/, "\n\n")' is not visible for me, because
newlines will be removed in the next step by '\s+'.

I made some tests (Ruby, not Ruby on Rails) and couldn't find any difference to
the following definition:

def word_wrap(text, line_width = 80)
text.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip
end

Wolfgang Nádasi-Donner

James Britt 02-04-2007 03:38 PM

Re: Change Proposal for "String#word_wrap" (Ruby on Rails - ActionView::Helpers::TextHelper)
 
Wolfgang Nádasi-Donner wrote:
> Hi!
>
> Hope this is the right place (I'm not a Ruby on Rails user).


Rails topics are better addressed on the Rails mailing list.

List info may be found at http://www.rubyonrails.org


--
James Britt

"I never dispute another person's delusions, just their facts."
- Len Bullard



All times are GMT. The time now is 05:55 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57