Sha256: cee60ae3092f20276bb7e3a82e67c5820a6aa3572a047f71e442a4d908f2bf20
Contents?: true
Size: 637 Bytes
Versions: 1
Compression:
Stored size: 637 Bytes
Contents
module Codebreaker module Loader PATH = 'lib/codebreaker/data/'.freeze EXTENCTION = '.yml'.freeze def self.load(file_name) file_name = PATH + file_name + EXTENCTION.to_s if File.exist?(file_name) YAML.load_file(file_name) else File.new(file_name, 'w') [] end end def self.save(obj, file_name) file_name = PATH + file_name + EXTENCTION.to_s stats = File.file?(file_name) && !File.zero?(file_name) ? YAML.load_file(file_name) : [] stats << obj file = File.open(file_name, 'w') file.write(stats.to_yaml) file.close end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
codebreaker_kub-0.1.2 | lib/codebreaker/loader.rb |