Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Change Proposal for "String#word_wrap" (Ruby on Rails - ActionView::Helpers::TextHelper
WoNáDo
2/4/2007 12:34:00 PM
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/ActionView/Helpers/TextHelper.ht...
):
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
1 Answer
James Britt
2/4/2007 3:39:00 PM
0
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.rubyo...
--
James Britt
"I never dispute another person's delusions, just their facts."
- Len Bullard
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Change Proposal for "String#word_wrap" (Ruby on Rails - ActionView::Helpers::TextHelper
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password