class CFPropertyList::Binary
def int_to_binary(value)
def int_to_binary(value) nbytes = 0 nbytes = 1 if value > 0xFF # 1 byte integer nbytes += 1 if value > 0xFFFF # 4 byte integer nbytes += 1 if value > 0xFFFFFFFF # 8 byte integer nbytes = 3 if value < 0 # 8 byte integer, since signed bdata = Binary.type_bytes("1", nbytes) # 1 is 0001, type indicator for integer buff = "" if(nbytes < 3) then fmt = "N" if(nbytes == 0) then fmt = "C" elsif(nbytes == 1) fmt = "n" end buff = [value].pack(fmt) else # 64 bit signed integer; we need the higher and the lower 32 bit of the value high_word = value >> 32 low_word = value & 0xFFFFFFFF buff = [high_word,low_word].pack("NN") end return bdata + buff end