Module: CBOR::Packed::String_Packed_CBOR

Defined in:
lib/cbor-packed.rb

Instance Method Summary collapse

Instance Method Details

#packed_merge(other, unpacker) ⇒ Object



399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/cbor-packed.rb', line 399

def packed_merge(other, unpacker)
  # add checks
  lhs = to_unpacked_cbor1(unpacker)
  rhs = other.to_unpacked_cbor1(unpacker)
  if CBOR::Tagged === rhs
    case rhs.tag
    when HEX_LC_TAG
      rhs = rhs.value.unpack("H*").first
    when HEX_UC_TAG
      rhs = rhs.value.unpack("H*").first.upcase
    else
      fail ArgumentError, "*** String#packed_merge: unknown tag #{rhs.tag} on rhs"
    end
  end
  begin
    lhs + rhs
  rescue => detail
    warn "** lhs = #{lhs.inspect}"
    warn "** rhs = #{rhs.inspect}"
    warn "** error: #{detail}"
    lhs + rhs.to_s
  end
end