# frozen_string_literal: true module Codebreaker class Verifier COMMANDS = { easy: 'easy', medium: 'medium', hell: 'hell' }.freeze class << self def verify_valid_name(name) name.is_a?(String) && verify_size?(name, min_size: Player::MIN_LENGTH_NAME, max_size: Player::MAX_LENGTH_NAME) end def verify_valid_difficult(difficult) COMMANDS.values.include?(difficult) end def verify_valid_code(code) return false unless code.is_a?(String) return false unless verify_size?(code, min_size: Game::LENGTH_CODE, max_size: Game::LENGTH_CODE) verify_include?(code) end private def verify_include?(code) code.chars.all? { |char| Game::VALID_NUMBERS.include?(char.to_i) } end def verify_size?(value, min_size:, max_size:) value.size.between?(min_size, max_size) end end end end