lib/rubygoods/string.rb in rubygoods-0.0.0.8 vs lib/rubygoods/string.rb in rubygoods-0.0.0.9

- old
+ new

@@ -7,6 +7,28 @@ self.force_encoding("UTF-8").gsub(/"/, udquote) end def quotenormalize self.force_encoding("UTF-8").gsub(/\\u0022/, '"') end + def spliteach(num) + strs = Array.new + counter = 0 + pos = 0 + str = "" + + self.each_char do |c| + if strs[pos] == nil + strs[pos] = "" + end + if counter == num + strs[pos] << str + pos += 1 + counter = 0 + str = "" + end + str = str + c.to_s + counter += 1 + end + + return strs + end end \ No newline at end of file