Class: MastermindGenerator::Difficulty
- Inherits:
-
Object
- Object
- MastermindGenerator::Difficulty
- Defined in:
- lib/mastermind_generator/difficulty.rb
Overview
Reprsents difficulty of the game It affects of how many items will be used for secret sequences
Instance Attribute Summary collapse
-
#item_count ⇒ Object
readonly
Returns the value of attribute item_count.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#sequence_length ⇒ Object
readonly
Returns the value of attribute sequence_length.
Instance Method Summary collapse
-
#initialize(level) ⇒ Difficulty
constructor
A new instance of Difficulty.
Constructor Details
#initialize(level) ⇒ Difficulty
Returns a new instance of Difficulty.
16 17 18 19 20 21 22 23 |
# File 'lib/mastermind_generator/difficulty.rb', line 16 def initialize(level) valid_difficulties = MastermindGenerator.configuration.difficulties raise InvalidDifficultyError unless valid_difficulties.key?(level) @level = level @item_count = valid_difficulties.dig(level, :item_count) @sequence_length = valid_difficulties.dig(level, :sequence_length) end |
Instance Attribute Details
#item_count ⇒ Object (readonly)
Returns the value of attribute item_count.
14 15 16 |
# File 'lib/mastermind_generator/difficulty.rb', line 14 def item_count @item_count end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
14 15 16 |
# File 'lib/mastermind_generator/difficulty.rb', line 14 def level @level end |
#sequence_length ⇒ Object (readonly)
Returns the value of attribute sequence_length.
14 15 16 |
# File 'lib/mastermind_generator/difficulty.rb', line 14 def sequence_length @sequence_length end |