BinData::Base#to_binary_s
returns "the string representation of this data object":
rectangle.to_binary_s
#=> "\f\x00\x00\x00\x00\x00\x00\x00\x00\x00"
This can be converted to a bit string via String#unpack
:
rectangle.to_binary_s.unpack('b*')
#=> ["00110000000000000000000000000000000000000000000000000000000000000000000000000000"]
Or to a bit array via:
rectangle.to_binary_s.unpack('b*')[0].chars.map(&:to_i)
#=> [0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]