Module: Polyfill::V2_3::String::Class::New::Method
- Defined in:
- lib/polyfill/v2_3/string/class/new.rb
Instance Method Summary collapse
Instance Method Details
#new(*args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/polyfill/v2_3/string/class/new.rb', line 7 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.encode!(encoding) if encoding str end |