lib/andrii_codebreaker/difficulty.rb in andrii_codebreaker-0.1.8 vs lib/andrii_codebreaker/difficulty.rb in andrii_codebreaker-0.1.10
- old
+ new
@@ -2,24 +2,21 @@
module AndriiCodebreaker
class Difficulty
include Constant
- attr_reader :difficulty
+ attr_reader :name, :hints, :attempts
- def initialize(difficulty)
- @difficulty = difficulty
+ def initialize(name)
+ validate_difficulty(name)
+ @name = name
+ @hints = DIFFICULTY[name.to_sym][:hints]
+ @attempts = DIFFICULTY[name.to_sym][:attempts]
end
- def hint
- difficult[:hints]
- end
+ def validate_difficulty(name)
+ return DIFFICULTY[name.to_sym] if DIFFICULTY.keys.include? name.to_sym
- def attempts
- difficult[:attempts]
- end
-
- def difficult
- DIFFICULTY[@difficulty.to_sym]
+ raise ArgumentError, I18n.t('game.difficulty_input_error')
end
end
end