]> git.cworth.org Git - sup/commitdiff
added String#normalize_whitespace and fixed String#wrap to not insert newlines
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 30 Dec 2006 15:13:50 +0000 (15:13 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 30 Dec 2006 15:13:50 +0000 (15:13 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@120 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/util.rb

index a1e19cc8c63f77c16e480856cc36725b62990b38..77209bf8033f5b5c0e445f442b12e62f18c35a39 100644 (file)
@@ -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