Class: Codebreaker::DifficultyFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/codebreaker/difficulty_factory.rb

Constant Summary collapse

DIFFICULTIES =
{

  easy: {
    name: 'easy',
    attempts: 15,
    hints: 2
  },
  medium: {
    name: 'medium',
    attempts: 10,
    hints: 1
  },
  hell: {
    name: 'hell',
    attempts: 5,
    hints: 1
  }

}.freeze

Class Method Summary collapse

Class Method Details

.generate(difficulty_name) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/codebreaker/difficulty_factory.rb', line 24

def self.generate(difficulty_name)
  case difficulty_name
  when DIFFICULTIES[:easy] then Difficulty.new(DIFFICULTIES[:easy])
  when DIFFICULTIES[:medium] then Difficulty.new(DIFFICULTIES[:medium])
  when DIFFICULTIES[:hell] then Difficulty.new(DIFFICULTIES[:hell])
  else raise Errors::InvalidDifficultyError
  end
end