module StoreData

Public Instance Methods

load_file(file) click to toggle source

Loads yaml from file or returns an empty hash if file doesn't exist.

# File lib/lector/other/storedata.rb, line 10
def load_file(file)
  return YAML.load_file(file) if File.exist?(file)
  {}
end
save_to_file(file, object) click to toggle source

Serializes an object and saves it to file.

# File lib/lector/other/storedata.rb, line 3
def save_to_file(file, object)
  File.open(file, 'w') do |f|
    f.write YAML.dump(object)
  end
end