Sha256: 18fccfd7218fd2a56577d6549df49d0249bed9e2a566bee8def3f0f59187d2af
Contents?: true
Size: 774 Bytes
Versions: 2
Compression:
Stored size: 774 Bytes
Contents
module Polyfill module V2_3 module String module Class module New module Method 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 end refine ::String.singleton_class do include Method end def self.included(base) base.include Method end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
polyfill-0.6.0 | lib/polyfill/v2_3/string/class/new.rb |
polyfill-0.5.0 | lib/polyfill/v2_3/string/class/new.rb |