# File ../lib/roller/BinaryIO/BinaryWriter.rb, line 35 def _write(value, size, format) # If not an array, make it into a single-element array so we can pack it. value = [value] unless value.is_a? Array num_bytes = value.size * size arr = value.pack(format * value.size) begin num_bytes_written = @handle.write(arr) rescue IOError => exception raise BinaryWriteError, exception.message end unless num_bytes_written == num_bytes raise BinaryWriteError, "Wrote #{num_bytes_written} bytes when expecting #{num_bytes} bytes" end end