commit 634c9d76daef87fbd4d74088bc38fdc3238a4aab
parent 9b078634a6dfc9ab12d4685180935eb50585e705
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Sat, 30 Dec 2006 15:13:50 +0000
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
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git 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