Class: Codebreaker::CodeMatcher

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

Constant Summary collapse

EXACT =
'+'
NON_EXACT =
'-'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#guessObject (readonly)

Returns the value of attribute guess.



8
9
10
# File 'lib/codebreaker/code_matcher.rb', line 8

def guess
  @guess
end

#secret_codeObject (readonly)

Returns the value of attribute secret_code.



8
9
10
# File 'lib/codebreaker/code_matcher.rb', line 8

def secret_code
  @secret_code
end

Instance Method Details

#match(secret_code, guess) ⇒ Object



10
11
12
13
14
# File 'lib/codebreaker/code_matcher.rb', line 10

def match(secret_code, guess)
  @secret_code = secret_code.split('')
  @guess = guess.split('')
  handle_matched_digits.join + handle_matched_digits_with_wrong_position.join
end