Sha256: f08cc83512850582f1aac03385254fea20aa3d00df75ff4eca888a7d96004fce
Contents?: true
Size: 530 Bytes
Versions: 1
Compression:
Stored size: 530 Bytes
Contents
require 'renc/version' # namespace module Renc def self.enc(obj, encoding = Encoding::UTF_8) case obj when String then obj.encode(encoding) when Hash then enc_hash(obj, encoding) when Array then enc_array(obj, encoding) else obj end end # private def self.enc_hash(obj, encoding) obj.each_with_object({}) do |args, h| key, val = args h[key] = enc(val, encoding) end end def self.enc_array(obj, encoding) obj.map { |val| enc(val, encoding) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
renc-0.2.0 | lib/renc.rb |