2

I was trying to learn how to save and read data from Ruby binary files while working with QtRuby but Marshal version of the values saved can't be read by Ruby. I know this wouldn't have happend with TXT files but I want to work with binary not TXT files.

Using Marshal.dump and Marshal.load methods definitely don't work at all. What can I do to ensure Ruby and QtRuby can read the same file without causing any issues?

Error Message: in 'load': incompatible marshal file format (can't be read) (TypeError)

  • 1
    What have you tried already? What errors are you getting? Also, we can't help you without seeing what you are doing. – alstonp Jul 21 '15 at 13:57
  • My idea when I posted this question here was to get some sort of example of how to do it correctly because handling a file the way Ruby does it definitely doesn't work at all. I have read something about QVariant that I haven't tried yet because I don't understand why I would use it instead of any Ruby class like String or Array or Hash. Besides it's quite common to find posts over the internet with just non working code rather than running code so I didn't want to post something that would only work if used with Ruby alone. If there still is somebody that could enlighten me on how to do it... – justconfused Jul 21 '15 at 22:01
  • Sorry if I'm double posting here but I guess I should tell people that I managed to save numbers (Fixnum) and read them from binary files. I still gotta try to load whole instances of common Ruby classes like arrays and hashes and later on even custom Ruby ones. – justconfused Jul 21 '15 at 22:33

0 Answers0