Class: MastermindGenerator::Difficulty

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_countObject (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

#levelObject (readonly)

Returns the value of attribute level.



14
15
16
# File 'lib/mastermind_generator/difficulty.rb', line 14

def level
  @level
end

#sequence_lengthObject (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