I have a problem with Object-Oriented Project Hangman - serialization part. I saved my code in serialize method, but when I try to unserialize it, I have a problem with it. I see all components of classes in the YAML file and when I try to reach them with code, I can't do it. I don't know where the problem is. Here is my serialize method and deserialize method.
def serialize
file = File.open('game.yml', 'w') do |f|
YAML.dump(self, f)
end
file.close
exit
end
def deserialize
File.open('game.yml', 'r') do |f|
p YAML.load(f)
end
# p file['word']
end
If you want to see my all codes, here is my GitHub and Repl
Repl : https://replit.com/@Burakkepuc/Hangman#main.rb
GitHub : https://github.com/Burakkepuc/Hangman