Module: CBOR::Packed::Array_Packed_CBOR

Defined in:
lib/cbor-packed.rb

Instance Method Summary collapse

Instance Method Details

#cbor_visit(&b) ⇒ Object



202
203
204
205
206
207
208
# File 'lib/cbor-packed.rb', line 202

def cbor_visit(&b)
  if yield self
    each do |o|
      o.cbor_visit(&b)
    end
  end
end

#packed_merge(other, unpacker) ⇒ Object



220
221
222
223
# File 'lib/cbor-packed.rb', line 220

def packed_merge(other, unpacker)
  # TODO: add checks
  to_unpacked_cbor1(unpacker) + other.to_unpacked_cbor1(unpacker)
end

#to_packed_cbor1(packer = Packer.from_item(self)) ⇒ Object



212
213
214
215
216
217
218
219
# File 'lib/cbor-packed.rb', line 212

def to_packed_cbor1(packer = Packer.from_item(self))
  if c = packer.has(self)
    c.to_unpacked_cbor1(unpacker)
  else
    # TODO: Find useful prefixes
    map {|x| x.to_packed_cbor1(packer)}
  end
end

#to_unpacked_cbor1(unpacker) ⇒ Object



209
210
211
# File 'lib/cbor-packed.rb', line 209

def to_unpacked_cbor1(unpacker)
  map {|x| x.to_unpacked_cbor1(unpacker)}
end