class Codebreaker::Difficulty
Constants
- LEVELS
Attributes
errors[R]
level[R]
Public Class Methods
new(name)
click to toggle source
# File lib/codebreaker/difficulty.rb, line 11 def initialize(name) @level = LEVELS.fetch(name&.to_sym) { nil } @errors = [] end
Public Instance Methods
valid?()
click to toggle source
# File lib/codebreaker/difficulty.rb, line 16 def valid? assert errors.empty? end
Private Instance Methods
assert()
click to toggle source
# File lib/codebreaker/difficulty.rb, line 23 def assert errors << I18n.t(:'errors.difficulty') if @level.nil? end