From 634c9d76daef87fbd4d74088bc38fdc3238a4aab Mon Sep 17 00:00:00 2001 From: wmorgan Date: Sat, 30 Dec 2006 15:13:50 +0000 Subject: [PATCH] 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 --- lib/sup/util.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 -- 2.45.2