class CodebreakerAp::Difficulty
Constants
- DIFFICULTY
Attributes
attempts[RW]
hints[R]
level[R]
Public Class Methods
new()
click to toggle source
# File lib/codebreaker_ap/entities/difficulty.rb, line 21 def initialize @level = nil @hints = nil @attempts = nil end
Public Instance Methods
hint(hints_code)
click to toggle source
# File lib/codebreaker_ap/entities/difficulty.rb, line 36 def hint(hints_code) return Message.new.no_hint if @hints.zero? @hints -= 1 hints_code.pop end
initialize_difficulty(level)
click to toggle source
# File lib/codebreaker_ap/entities/difficulty.rb, line 27 def initialize_difficulty(level) check = Validator.new check.validate_difficulty(level, DIFFICULTY.keys) return check.errors unless check.errors.empty? @level = level setup_difficulty end
Private Instance Methods
setup_difficulty()
click to toggle source
# File lib/codebreaker_ap/entities/difficulty.rb, line 45 def setup_difficulty difficulty_options = DIFFICULTY[@level.to_sym] @hints = difficulty_options[:hints] @attempts = difficulty_options[:attempts] end