Class: Codebreaker::Difficulty

Inherits:
Object
  • Object
show all
Defined in:
lib/app/entities/difficulty.rb

Constant Summary collapse

DIFFICULTIES =
{
  simple: {
    hints: 2,
    attempts: 15,
    level: 'simple'
  },

  middle: {
    hints: 1,
    attempts: 10,
    level: 'middle'
  },

  hard: {
    hints: 1,
    attempts: 5,
    level: 'hard'
  }
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Difficulty

Returns a new instance of Difficulty.



27
28
29
# File 'lib/app/entities/difficulty.rb', line 27

def initialize(input)
  @level = DIFFICULTIES[input]
end

Instance Attribute Details

#levelObject (readonly)

Returns the value of attribute level.



5
6
7
# File 'lib/app/entities/difficulty.rb', line 5

def level
  @level
end

Class Method Details

.find(input) ⇒ Object



31
32
33
34
35
36
# File 'lib/app/entities/difficulty.rb', line 31

def self.find(input)
  input_as_key = input.to_sym
  return unless DIFFICULTIES.key?(input_as_key)

  new(input_as_key)
end