Sha256: 8b762b0d6a3523fa8eeebcf5f30c97bc0346d256827be4dc83a09735994e3e49

Contents?: true

Size: 757 Bytes

Versions: 4

Compression:

Stored size: 757 Bytes

Contents

class ::String
  def squish
    self.force_encoding("UTF-8").gsub(/\s+/, " ").strip
  end
  def antiinject
    udquote = '"'.force_encoding("UTF-8").unpack('U*').map{ |i| "\\u" + i.to_s(16).rjust(4, '0') }.join
    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
    if str != ""
      strs[pos] << str
    end
    return strs
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubygoods-0.0.1.1 lib/rubygoods/string.rb
rubygoods-0.0.1 lib/rubygoods/string.rb
rubygoods-0.0.0.12 lib/rubygoods/string.rb
rubygoods-0.0.0.10 lib/rubygoods/string.rb