lib/codeguessing/console.rb in codeguessing-0.5 vs lib/codeguessing/console.rb in codeguessing-0.5.1
- old
+ new
@@ -1,8 +1,8 @@
module Codeguessing
class Console
- attr_reader :game, :scores
+ attr_reader :game, :scores, :path
MESSAGE = YAML.load_file(File.join(File.dirname(__FILE__), 'data/messages.yml'))
def initialize
@path = File.join(File.dirname(__FILE__), 'data/scores.yml')
@@ -48,10 +48,10 @@
def load(path)
YAML.load_file(path) if File.exist?(path)
end
- def save(name: 'Anonim', path: @path)
+ def save(name = 'Anonim')
return puts MESSAGE['cant_save'] unless game.win?
@scores << game.cur_score(name.chomp)
File.new(path, 'w') unless File.exist?(path)
File.open(path, "r+") do |f|
f.write(scores.to_yaml)