On Sat, Feb 4, 2012 at 4:24 AM, Patrick Bayford <pbayford / talktalk.net> wrote: > Robert Klemme wrote in post #1044013: >> On Fri, Feb 3, 2012 at 11:02 PM, Patrick Bayford <pbayford / talktalk.net> >> wrote: >>> Some assistance please - I have a Ruby project, which I started in Ruby >>> 1.8.6/7, some time ago. It involves several custom data classes, which >>> can have up to 500 multi-field items in "lists". The size of the data >>> means that file storage is crucial, however, with the massive changes >>> made to yaml.rb in Ruby 1.9.n, I find that, although I can load existing >>> data from file, I can't find a way to save it back to file. Anyone got >>> any suggestions where to start? >> >> Did you consider using Marshal? >> >>> I'd prefer using a proper database but can't get any of those to behave >>> properly either!!! >> >> What does that mean? > I did try using Marshal, however, while the examples show how to use > dump & load for in memory use, there was not enough information for me > to get it to write to a file! I don't have enough Ruby experience yet to > work out how to do this sort of stuff - I'm a Pascal/Delphi man by > choice, and serializing objects is nearly all down to the coder. The docs at http://www.ruby-doc.org/core-1.9.3/Marshal.html#method-c-dump mention that you can pass an IO object. file_name = "foo.bin" # store File.open(file_name, 'wb') {|io| Marshal.dump(obj, io)} # load obj = File.open(file_name, 'rb') {|io| Marshal.load(io)} You should take care that "obj" is an object containing everything you want to serialize. > As to the database comment, I have so far been unable to get mySQL > working with Ruby 1.9, and don't (yet) know enough SQLite to make it's > use practical. I have SQL Server too, but that has even poorer support > documentation, as far as Ruby is concerned. Most of my attempts have > failed at the connect stage. I'd try Marshal first. Much simpler to use and quite fast. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/