I had a large Ruby object which was a result of multiple API calls. I needed to persist it quickly so that I could retrieve it in my next Pry session and resume my work on it instantly, without spamming the remote API with a lot of requests again.

To save an object, simply do this:

File.open('ruby_obj', 'w') { |f| f.write(YAML.dump(result)) }

And to retrieve it later:

result = YAML.load(File.read('ruby_obj'))