class Difficult attr_reader :level def initialize(level) @level = level.downcase end def to_i case @level when name('hell') then 1 when name('medium') then 2 when name('easy') then 3 end end private def name(difficult) Codebreaker::Game::DIFFICULTS[difficult.to_sym][:name] end end