From: wmorgan Date: Sat, 30 Dec 2006 15:13:50 +0000 (+0000) Subject: added String#normalize_whitespace and fixed String#wrap to not insert newlines X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=634c9d76daef87fbd4d74088bc38fdc3238a4aab;p=sup added String#normalize_whitespace and fixed String#wrap to not insert newlines git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@120 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- diff --git a/lib/sup/util.rb b/lib/sup/util.rb index a1e19cc..77209bf 100644 --- a/lib/sup/util.rb +++ b/lib/sup/util.rb @@ -70,15 +70,19 @@ class String while s.length > len cut = s[0 ... len].rindex(/\s/) if cut - ret << s[0 ... cut] + "\n" + ret << s[0 ... cut] s = s[(cut + 1) .. -1] else - ret << s[0 ... len] + "\n" + ret << s[0 ... len] s = s[len .. -1] end end ret << s end + + def normalize_whitespace + gsub(/\t/, " ").gsub(/\r/, "") + end end class Numeric