Class: CodeBrkrGameTraining::CodeComparator

Inherits:
Object
  • Object
show all
Includes:
Validator
Defined in:
lib/code_brkr_game_training/entities/code_comparator.rb

Overview

Class for comparing the hidden code and the code entered by the user

Constant Summary

Constants included from Validator

Validator::DataValidError

Instance Method Summary collapse

Methods included from Validator

#check_contain_hash_key, #check_length, #check_type

Constructor Details

#initialize(secret_code, user_code) ⇒ CodeComparator

Returns a new instance of CodeComparator.



9
10
11
12
13
14
# File 'lib/code_brkr_game_training/entities/code_comparator.rb', line 9

def initialize(secret_code, user_code)
  check_code_format(user_code)

  @secret_code = secret_code
  @user_code = user_code
end

Instance Method Details

#compare_codesObject



16
17
18
19
20
21
22
# File 'lib/code_brkr_game_training/entities/code_comparator.rb', line 16

def compare_codes
  {
    in_positions: check_in_positions,
    out_of_positions: check_out_positions,
    not_guessed: check_not_guessed
  }
end