Class: CBOR::Transform_j
Instance Method Summary
collapse
Methods inherited from Transform
#transform, #transform_array, #transform_bool, #transform_float, #transform_integer, #transform_nil, #transform_text
Instance Method Details
15
16
17
|
# File 'lib/cbor-transform-j.rb', line 15
def transform_bytes(obj)
{'@@!b': ::Base64.urlsafe_encode64(obj, padding: false)}
end
|
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/cbor-transform-j.rb', line 19
def transform_hash(obj)
Hash[obj.map {|k, v| [ (
kt = transform(k)
if (String === kt && kt.encoding != Encoding::BINARY)
kt
else
'@@!:' << JSON.generate(kt)
end
),
transform(v)]}]
end
|
CBOR::Transform_j.new(1).transform [1, “a”, “b”.b, CBOR::Simple.new(2), CBOR::Tagged.new(1, 2), 1, 2=> 3]
11
12
13
|
# File 'lib/cbor-transform-j.rb', line 11
def transform_simple(obj)
{'@@!s': obj.value}
end
|
31
32
33
|
# File 'lib/cbor-transform-j.rb', line 31
def transform_tag(obj)
{"@@!t#{obj.tag}": transform(obj.value)}
end
|