Search code examples
rubybindata

Ruby, BinData, boolean not recognized as object type


The code below doesn't work, yet the type boolean exists and I used it in another class the same way, why doesn't it work here?

require 'bindata'
class TESTSTUFF < BinData::Record
  array  :boolstuff, :type => :boolean, :initial_length => 8
end

The error is: unknown type 'boolean' in TESTSTUFF (TypeError)


Solution

  • There is no such parameter as boolean in bindata. Use bit1 that's a 1-bit big endian integer and may be used as boolean. Look at the docs.