Per the example below, I am able to create a new BinData::Record that includes a BinData::Array element, and am able to create a binary string from new objects of that class type. However, when I then try to instantiate a new object from that binary string, the new object is not properly created.
require 'bindata'
class IntegerArray < BinData::Array
uint16le initial_value: 0
end
class Test < BinData::Record
integer_array :field
end
obj = Test.new
obj[:field] << 15
str = obj.to_binary_s
puts obj.inspect # {"field"=>[15]}
puts str.inspect # "\x0F\x00"
puts str.unpack("S<*") # 15
newobj = Test.read(str)
puts newobj.inspect # {"field"=>[]}
I've tried removing the array's initial_value with the same results. Thanks in advance for your help.