module Codebreaker class FileStorage def initialize(path) @path = path end def load File.file?(@path) ? YAML.load_file(@path) : nil end def save(data) Pathname(@path).dirname.mkpath File.write(@path, data.to_yaml) end end end