Class: Codebreaker::Difficulties

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

Constant Summary collapse

LEVELS =
{
  easy: {
    attempts: 15,
    hints: 2
  },
  medium: {
    attempts: 10,
    hints: 2
  },
  hell: {
    attempts: 5,
    hints: 1
  }
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(difficulties) ⇒ Difficulties

Returns a new instance of Difficulties.



21
22
23
24
25
# File 'lib/codebreaker/entities/difficulties.rb', line 21

def initialize(difficulties)
  @level = difficulties
  @attempts = LEVELS[difficulties.to_sym][:attempts]
  @hints = LEVELS[difficulties.to_sym][:hints]
end

Instance Attribute Details

#attemptsObject (readonly)

Returns the value of attribute attempts.



19
20
21
# File 'lib/codebreaker/entities/difficulties.rb', line 19

def attempts
  @attempts
end

#hintsObject (readonly)

Returns the value of attribute hints.



19
20
21
# File 'lib/codebreaker/entities/difficulties.rb', line 19

def hints
  @hints
end

#levelObject (readonly)

Returns the value of attribute level.



19
20
21
# File 'lib/codebreaker/entities/difficulties.rb', line 19

def level
  @level
end

Class Method Details

.valid_difficult(difficulties) ⇒ Object



28
29
30
# File 'lib/codebreaker/entities/difficulties.rb', line 28

def valid_difficult(difficulties)
  Verifier.verify_valid_difficult(difficulties)
end