Class: AndriiCodebreaker::Difficulty
- Inherits:
-
Object
- Object
- AndriiCodebreaker::Difficulty
- Includes:
- Constant
- Defined in:
- lib/andrii_codebreaker/difficulty.rb
Constant Summary
Constants included from Constant
Constant::CODE_LENGTH, Constant::CODE_LENGTH_COUNT, Constant::CODE_START_LENGTH, Constant::DIFFICULTY, Constant::DIFFICULTY_SORT, Constant::LALA, Constant::MINUS, Constant::NAME_MAX_LENGTH, Constant::NAME_MIN_LENGTH, Constant::PLUS, Constant::RANGE_SECRET_CODE, Constant::WIN
Instance Attribute Summary collapse
-
#attempts ⇒ Object
readonly
Returns the value of attribute attempts.
-
#hints ⇒ Object
readonly
Returns the value of attribute hints.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ Difficulty
constructor
A new instance of Difficulty.
- #validate_difficulty(name) ⇒ Object
Constructor Details
#initialize(name) ⇒ Difficulty
Returns a new instance of Difficulty.
9 10 11 12 13 14 |
# File 'lib/andrii_codebreaker/difficulty.rb', line 9 def initialize(name) validate_difficulty(name) @name = name @hints = DIFFICULTY[name.to_sym][:hints] @attempts = DIFFICULTY[name.to_sym][:attempts] end |
Instance Attribute Details
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
7 8 9 |
# File 'lib/andrii_codebreaker/difficulty.rb', line 7 def attempts @attempts end |
#hints ⇒ Object (readonly)
Returns the value of attribute hints.
7 8 9 |
# File 'lib/andrii_codebreaker/difficulty.rb', line 7 def hints @hints end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/andrii_codebreaker/difficulty.rb', line 7 def name @name end |
Instance Method Details
#validate_difficulty(name) ⇒ Object
16 17 18 19 20 |
# File 'lib/andrii_codebreaker/difficulty.rb', line 16 def validate_difficulty(name) return DIFFICULTY[name.to_sym] if DIFFICULTY.keys.include? name.to_sym raise ArgumentError end |