Module: CBOR::ArrayHelper

Defined in:
lib/libcbor/helpers.rb

Overview

Provides the #to_cbor (or equivalent) method for Arrayss

Instance Method Summary collapse

Instance Method Details

#__libcbor_to_cborString

Encodes Arrayss. The resulting item is always a definite array.

The members are encoded recursively using the to_cbor method or its equivalent

Returns:

  • (String)

    The CBOR representation



74
75
76
77
78
79
80
81
# File 'lib/libcbor/helpers.rb', line 74

def __libcbor_to_cbor
	@@bfr ||= FFI::Buffer.new(:uchar, 9)
	header = @@bfr.get_bytes(0, LibCBOR.cbor_encode_array_start(count, @@bfr, 9))
	each do |member|
		header += member.public_send(CBOR.method_name)
	end
	header
end