Sha256: a65b968f1e411a02d32e19b5d0fed16ff2219d3e22354d2a5b61a6a157630dd2

Contents?: true

Size: 453 Bytes

Versions: 1

Compression:

Stored size: 453 Bytes

Contents

module Codebreaker
  module Score
    def save_score
      puts 'Do you want to save your score in score file?(y/n)'
      save_score_file if agree?
      exit
    end

    private
    def save_score_file
      name = input_name
      path = File.expand_path("../../score/#{name}_score.txt", __FILE__)
      File.open(path, 'a') { |file| file.puts "#{@game.score} - #{Time.now.asctime}" }
      puts "You score saved in file: #{path}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Codebreaker_RG2016-0.2.0 lib/codebreaker/modules/score.rb