require_relative './errors/errors' class Difficult include Errors DIFFICULTS = { easy: 'easy', medium: 'medium', hell: 'hell' }.freeze attr_reader :level def initialize(level) raise WrongDifficultError unless valid? level @level = level.downcase end def to_i case @level.downcase when DIFFICULTS[:hell] then 1 when DIFFICULTS[:medium] then 2 when DIFFICULTS[:easy] then 3 end end private def valid?(level) level.is_a?(String) && DIFFICULTS.values.include?(level.downcase) end end