Class: Codebreaker::GuessChecker
- Inherits:
-
Object
- Object
- Codebreaker::GuessChecker
- Defined in:
- lib/codebreaker/guess.rb
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #check_guess ⇒ Object
-
#initialize(guess, secret_code) ⇒ GuessChecker
constructor
A new instance of GuessChecker.
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
#store ⇒ Object (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_guess ⇒ Object
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 |