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
251 252 253 254 255 256 257 258 |
# File 'lib/cbor-packed.rb', line 251 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
270 271 272 273 |
# File 'lib/cbor-packed.rb', line 270 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
262 263 264 265 266 267 268 269 |
# File 'lib/cbor-packed.rb', line 262 def to_packed_cbor1(packer = Packer.from_item(self)) if c = packer.has(self) c.to_packed_cbor1(packer) 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
259 260 261 |
# File 'lib/cbor-packed.rb', line 259 def to_unpacked_cbor1(unpacker) Hash[map {|k, v| [k.to_unpacked_cbor1(unpacker), v.to_unpacked_cbor1(unpacker)]}] end |