module Polyfill::V2_3::String::ClassMethods

Public Instance Methods

new(*args) click to toggle source
Calls superclass method
# File lib/polyfill/v2_3/string.rb, line 5
def new(*args)
  hash, others = args.partition { |arg| arg.is_a?(::Hash) }
  hash = hash.first
  encoding = hash && hash.delete(:encoding)

  if hash && !hash.keys.empty?
    raise ArgumentError, "unknown keyword: #{hash.keys.first}"
  end

  str = super(*others)
  str.force_encoding(encoding) if encoding
  str
end