Class: Codebreaker::Entities::Processor
- Inherits:
-
Object
- Object
- Codebreaker::Entities::Processor
- Defined in:
- lib/codebreaker_marian/entities/processor.rb
Constant Summary collapse
- MATCHED_DIGIT_CHAR =
'+'- UNMATCHED_DIGIT_CHAR =
'-'- WRONG_DIGIT_CHAR =
' '
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#guess ⇒ Object
readonly
Returns the value of attribute guess.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
10 11 12 |
# File 'lib/codebreaker_marian/entities/processor.rb', line 10 def code @code end |
#guess ⇒ Object (readonly)
Returns the value of attribute guess.
10 11 12 |
# File 'lib/codebreaker_marian/entities/processor.rb', line 10 def guess @guess end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
10 11 12 |
# File 'lib/codebreaker_marian/entities/processor.rb', line 10 def result @result end |
Instance Method Details
#secret_code_proc(code, guess) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/codebreaker_marian/entities/processor.rb', line 12 def secret_code_proc(code, guess) @code = code.split('') @guess = guess.split('') answer = handle_matched_digits.join + handle_matched_digits_with_wrong_position.join (code.length - answer.length).times { answer << WRONG_DIGIT_CHAR } answer end |