class CodebreakerAp::Validator

Attributes

errors[R]

Public Class Methods

new() click to toggle source
# File lib/codebreaker_ap/entities/validator.rb, line 7
def initialize
  @errors = []
end

Public Instance Methods

validate_difficulty(level, difficulty_keys) click to toggle source
# File lib/codebreaker_ap/entities/validator.rb, line 11
def validate_difficulty(level, difficulty_keys)
  check_difficulty(level.to_sym, difficulty_keys)
rescue WrongDifficultyError => e
  @errors.push(e)
end
validate_length(name, name_length) click to toggle source
# File lib/codebreaker_ap/entities/validator.rb, line 17
def validate_length(name, name_length)
  check_length(name, name_length)
rescue WrongLengthError => e
  @errors.push(e)
end
validate_player_answer(answer, answer_length, answer_chars_range) click to toggle source
# File lib/codebreaker_ap/entities/validator.rb, line 23
def validate_player_answer(answer, answer_length, answer_chars_range)
  validate_length(answer, answer_length)
  check_chars_range(answer, answer_chars_range)
rescue WrongNumbersError => e
  @errors.push(e)
end