Sha256: 5007a5114c8fe6b9d1002a6b196779a94b93ee7e27c4aeb2d39ec09aae269365
Contents?: true
Size: 663 Bytes
Versions: 2
Compression:
Stored size: 663 Bytes
Contents
module AlexCodebreaker class GameManager FILENAME_EXTENSION = '.yml'.freeze def initialize(game_id) @game_id = game_id end def save(game) unless File.directory?(AlexCodebreaker.configuration.games_folder_path) FileUtils.mkdir_p(AlexCodebreaker.configuration.games_folder_path) end File.open(game_file_path, 'w') { |file| file.write(game.to_yaml) } end def load return unless File.exist?(game_file_path) YAML.load_file(game_file_path) end private def game_file_path "#{AlexCodebreaker.configuration.games_folder_path}/#{@game_id}#{FILENAME_EXTENSION}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alex_codebreaker-0.2.3 | lib/alex_codebreaker/game_manager.rb |
alex_codebreaker-0.2.2 | lib/alex_codebreaker/game_manager.rb |