Class: CodebreakerKirill::User

Inherits:
Object
  • Object
show all
Includes:
Settings
Defined in:
lib/codebreaker_kirill/user.rb

Constant Summary

Constants included from Settings

Settings::CODE_LENGTH, Settings::DIFFICULTY, Settings::GUESS_LENGTH, Settings::NAME_MAX_LENGTH, Settings::NAME_MIN_LENGTH, Settings::NEGATIVE_RESPONSE, Settings::POSITIVE_RESPONSE, Settings::RANDOM_RANGE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, difficulty) ⇒ User

Returns a new instance of User.



10
11
12
13
14
15
16
17
# File 'lib/codebreaker_kirill/user.rb', line 10

def initialize(name, difficulty)
  validation(name, difficulty)
  @difficulty = difficulty
  @name = name
  @level = Settings::DIFFICULTY[@difficulty]
  @attempts_used = 0
  @hints_used = 0
end

Instance Attribute Details

#attempts_usedObject

Returns the value of attribute attempts_used.



7
8
9
# File 'lib/codebreaker_kirill/user.rb', line 7

def attempts_used
  @attempts_used
end

#difficultyObject (readonly)

Returns the value of attribute difficulty.



8
9
10
# File 'lib/codebreaker_kirill/user.rb', line 8

def difficulty
  @difficulty
end

#hints_usedObject

Returns the value of attribute hints_used.



7
8
9
# File 'lib/codebreaker_kirill/user.rb', line 7

def hints_used
  @hints_used
end

#levelObject (readonly)

Returns the value of attribute level.



8
9
10
# File 'lib/codebreaker_kirill/user.rb', line 8

def level
  @level
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/codebreaker_kirill/user.rb', line 8

def name
  @name
end

Instance Method Details

#validation(name, difficulty) ⇒ Object



19
20
21
22
# File 'lib/codebreaker_kirill/user.rb', line 19

def validation(name, difficulty)
  Validations.validate_name(name)
  Validations.validate_difficulty(difficulty)
end