class Session attr_reader :difficulty_name, :difficulty_level, :attempts_total, :hints_total attr_accessor :player_name, :attempts_used, :hints_used def initialize @attempts_used = 0 @hints_used = 0 end def difficulty_manager(difficulty) if DifficultyLevels::DIFFICULTY_LEVELS.include?(difficulty) add_difficulty(DifficultyLevels::DIFFICULTY_LEVELS[difficulty]) end raise WrongDifficulty unless DifficultyLevels::DIFFICULTY_LEVELS.include?(difficulty) end def save_session_statistic File.open(Files::STATS_FILE, 'a') do |file| file.write(to_yaml) end end private def add_difficulty(difficulty) @difficulty_name = difficulty[:name] @difficulty_level = difficulty[:level] @attempts_total = difficulty[:attempts_total] @hints_total = difficulty[:hints_total] end end