What I want do is to save Ruby objects for caching to disk. That works nice using YAML or JSON. But when I read that file I want to convert the content back to an object of a special type.
In my case I am using the flickraw library and am using some Ruby code for downloading photos from Flickr. There is a method in flickraw
called
photo_info = flickraw.photos.getInfo(:photo_id => photo_id)
which gives me a lot of information about the photo. I dump this information to a file which works great. Since I do not want to download this information every time I run my code but want to read the cached data from the written file I do open the file and then do
file = File.open('photo.meta', 'r')
photo_info = YAML::load(file.read)
Now I need photo_info
to become of the object type the getInfo
method is returning when using flickraw.
How can I do this in Ruby?