You could craete a class like:
class PackedArray
def initialize(array)
@packed_array = array.pack('S9s')
end
def [](key)
data = @packed_array.unpack('S9s')
data[key]
end
def []=(key, val)
k = @packed_array.unpack('S9s')
k[key]=val
@packed_array = k.pack('S9s')
end
end
Then, fill your image_data[i][j]
with an instance of this class. E.g.
for i in [0..image_data.size]
for j in [0..image_data[i].size]
image_data[i][j] = new PackedArray(image_data[i][j])
end
end
And finally you can simply use:
if image_data[i][j+1][BLOB] == 0
Without needing of packing/unpacking manually.