Sha256: ba74cc503ea54bce6d68ce134e642143a5fc8b764f169d650e6ff4e98098554f
Contents?: true
Size: 932 Bytes
Versions: 11
Compression:
Stored size: 932 Bytes
Contents
# 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
Version data entries
11 entries across 11 versions & 1 rubygems