Sha256: 803bff9e3b0745da5bffc1480b04932ba00ea8f94b701d9639e086457801bf55

Contents?: true

Size: 529 Bytes

Versions: 6

Compression:

Stored size: 529 Bytes

Contents

# patch with 2.1 methods if not defined
class String
  unless defined? b
    def b
      dup.force_encoding 'binary'
    end
  end

  unless defined? scrub
    # NOTE: block unsupported
    def scrub replacement=nil
      if replacement
        replacement = replacement.encode 'UTF-16BE'
      else
        replacement = "\xFF\xFD".force_encoding 'UTF-16BE'
      end
      r = encode("UTF-16BE", undef: :replace, invalid: :replace, replace: replacement)
      r.encode("UTF-8").gsub("\0".encode("UTF-8"), '')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nyara-0.1.pre.2 lib/nyara/patches/string.rb
nyara-0.1.pre.1 lib/nyara/patches/string.rb
nyara-0.1.pre.0 lib/nyara/patches/string.rb
nyara-0.0.1.pre.9 lib/nyara/patches/string.rb
nyara-0.0.1.pre.8 lib/nyara/patches/string.rb
nyara-0.0.1.pre.6 lib/nyara/patches/string.rb