Class: Codebreaker::GuessChecker

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(guess, secret_code) ⇒ GuessChecker

Returns a new instance of GuessChecker.



7
8
9
10
11
# File 'lib/codebreaker/guess.rb', line 7

def initialize(guess, secret_code)
  @store = { index: 0, include: 0 }
  @encryption = secret_code
  @hypothesis = guess
end

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



5
6
7
# File 'lib/codebreaker/guess.rb', line 5

def store
  @store
end

Instance Method Details

#check_guessObject



13
14
15
16
17
18
19
# File 'lib/codebreaker/guess.rb', line 13

def check_guess
  temp_encryption = @encryption.dup
  temp_hypothesis = @hypothesis.dup
  each_for_index(temp_hypothesis, temp_encryption)
  each_for_include(temp_hypothesis, temp_encryption)
  @store
end