Sha256: db3d4cce4c0c9df71b9e1ea38a729573282d5fc0c281dff803ee9ca340311a90

Contents?: true

Size: 620 Bytes

Versions: 10

Compression:

Stored size: 620 Bytes

Contents

module Polyfill
  module V2_3
    module String
      module ClassMethods
        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
      end

      def +@
        frozen? ? dup : self
      end

      def -@
        frozen? ? self : dup.freeze
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
polyfill-1.9.0 lib/polyfill/v2_3/string.rb
polyfill-1.8.0 lib/polyfill/v2_3/string.rb
polyfill-1.7.0 lib/polyfill/v2_3/string.rb
polyfill-1.6.0 lib/polyfill/v2_3/string.rb
polyfill-1.5.0 lib/polyfill/v2_3/string.rb
polyfill-1.4.0 lib/polyfill/v2_3/string.rb
polyfill-1.3.0 lib/polyfill/v2_3/string.rb
polyfill-1.2.0 lib/polyfill/v2_3/string.rb
polyfill-1.1.0 lib/polyfill/v2_3/string.rb
polyfill-1.0.1 lib/polyfill/v2_3/string.rb