class CBOR::Transform
Public Instance Methods
Source
# File lib/cbor-transform.rb, line 3 def transform(obj) case obj when NilClass transform_nil(obj) when FalseClass, TrueClass transform_bool(obj) when CBOR::Simple transform_simple(obj) when Float transform_float(obj) when Integer transform_integer(obj) # XXX should probably handle Symbol when String case obj.encoding when Encoding::BINARY transform_bytes(obj) else transform_text(obj) end when Array transform_array(obj) when Hash transform_hash(obj) when CBOR::Tagged transform_tag(obj) end end
Source
# File lib/cbor-transform.rb, line 60 def transform_array(obj) obj.map {|x| transform(x)} end
Source
# File lib/cbor-transform.rb, line 64 def transform_hash(obj) Hash[obj.map {|k, v| [transform(k), transform(v)]}] end
Source
# File lib/cbor-transform.rb, line 48 def transform_integer(obj) obj end
Source
# File lib/cbor-transform.rb, line 40 def transform_simple(obj) obj end
Source
# File lib/cbor-transform.rb, line 68 def transform_tag(obj) CBOR::Tagged.new(transform(obj.tag), transform(obj.value)) end