Module: NewSuperCodebreaker2021::DBMethods
- Included in:
- Game
- Defined in:
- lib/new_super_codebreaker_2021/db_methods.rb
Instance Method Summary collapse
Instance Method Details
#load_file(file) ⇒ Object
11 12 13 14 15 |
# File 'lib/new_super_codebreaker_2021/db_methods.rb', line 11 def load_file(file) YAML.load_file(file) rescue Errno::ENOENT [] end |
#save(user, file) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/new_super_codebreaker_2021/db_methods.rb', line 3 def save(user, file) = load_file(file) .push(user) File.open(file, 'w') do |filename| YAML.dump(, filename) end end |