Module: CBOR::Packed::Hash_Packed_CBOR
- Defined in:
- lib/cbor-packed.rb
Instance Method Summary collapse
- #cbor_visit(&b) ⇒ Object
- #packed_merge(other, unpacker) ⇒ Object
- #to_packed_cbor1(packer = Packer.from_item(self)) ⇒ Object
- #to_unpacked_cbor1(unpacker) ⇒ Object
Instance Method Details
#cbor_visit(&b) ⇒ Object
228 229 230 231 232 233 234 235 |
# File 'lib/cbor-packed.rb', line 228 def cbor_visit(&b) if yield self each do |k, v| k.cbor_visit(&b) v.cbor_visit(&b) end end end |
#packed_merge(other, unpacker) ⇒ Object
247 248 249 250 |
# File 'lib/cbor-packed.rb', line 247 def packed_merge(other, unpacker) # TODO: add checks to_unpacked_cbor1(unpacker).merge other.to_unpacked_cbor1(unpacker) end |
#to_packed_cbor1(packer = Packer.from_item(self)) ⇒ Object
239 240 241 242 243 244 245 246 |
# File 'lib/cbor-packed.rb', line 239 def to_packed_cbor1(packer = Packer.from_item(self)) if c = packer.has(self) c.to_unpacked_cbor1(unpacker) else # TODO: Find useful prefixes Hash[map {|k, v| [k.to_packed_cbor1(packer), v.to_packed_cbor1(packer)]}] end end |
#to_unpacked_cbor1(unpacker) ⇒ Object
236 237 238 |
# File 'lib/cbor-packed.rb', line 236 def to_unpacked_cbor1(unpacker) Hash[map {|k, v| [k.to_unpacked_cbor1(unpacker), v.to_unpacked_cbor1(unpacker)]}] end |