Sha256: c8807683ce7038eb0abade7eb60a6c607a7832d11348129c4576db7ac7084fce

Contents?: true

Size: 637 Bytes

Versions: 2

Compression:

Stored size: 637 Bytes

Contents

class Object
  def _utf8
    self
  end

  def _binary
    self
  end
end

if RUBY_VERSION >= '1.9'
  class Array
    def _utf8
      map { |a| a._utf8 }
    end

    def _binary
      map { |a| a._binary }
    end
  end

  class Regexp
    def _utf8
      Regexp.new(to_s._utf8)
    end

    def _binary
      Regexp.new(to_s._binary)
    end
  end

  class Hash
    def _utf8
      {}.tap{|h| 
        keys.each { |k| h[k.frozen? ? k.dup._utf8 : k._utf8] = self[k]._utf8 }
      }
    end

    def _binary
      {}.tap{|h| 
        keys.each { |k| h[k.frozen? ? k.dup._binary : k._binary] = self[k]._binary }
      }
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
encoding-kawai-0.2 lib/encoding-kawai/object.rb
encoding-kawai-0.1 lib/encoding-kawai/object.rb