lib/codebreaker_mats/matcher.rb in codebreaker_mats-0.1.0 vs lib/codebreaker_mats/matcher.rb in codebreaker_mats-0.1.1
- old
+ new
@@ -14,27 +14,19 @@
def secret_code=(secret_code)
@secret_code_hash = array_to_hash_of_positions(unify_code(secret_code))
end
def match?(guess)
- raise Exceptions::InvalidGuessFormat unless valid_code?(guess)
-
match(array_to_hash_of_positions(unify_code(guess)))
bulls == 4
end
def marks
marker.mark(bulls, cows)
end
private
-
- def valid_code?(code)
- code = code.join('') if code.is_a?(Array)
-
- code.match(/^[1-6]{4}$/)
- end
def unify_code(code)
code.is_a?(String) ? code.split('') : code
end