class Codebreaker::Storage
Constants
- PATH_TO_FILE
Public Class Methods
new()
click to toggle source
# File lib/codebreaker/storage.rb, line 5 def initialize Dir.mkdir(File.dirname(PATH_TO_FILE)) && File.new(PATH_TO_FILE, 'w') unless file_exist? end
Public Instance Methods
file_exist?()
click to toggle source
# File lib/codebreaker/storage.rb, line 13 def file_exist? File.exist?(PATH_TO_FILE) end
load_from_file()
click to toggle source
# File lib/codebreaker/storage.rb, line 17 def load_from_file Psych.load_stream(File.read(PATH_TO_FILE)) end
save_to_file(data)
click to toggle source
# File lib/codebreaker/storage.rb, line 9 def save_to_file(data) File.open(PATH_TO_FILE, 'a') { |file| file.write(data.to_yaml) } end