module Codebreaker::Validator
Constants
- CB_ARRAY_SIZE
- COMMANDS
- GAME_NUMBER_RANGE
- LEVELS
- NAME_SIZE
Public Instance Methods
valid_input?(input, validator)
click to toggle source
# File lib/modules/validator.rb, line 10 def valid_input?(input, validator) goodbye if input == COMMANDS[:exit] case validator when 'guess' return false unless input.size == CB_ARRAY_SIZE return true if input == COMMANDS[:hint] input.split('').map { |number| GAME_NUMBER_RANGE.cover?(number.to_i) }.all? when 'name' NAME_SIZE.include?(input.size) when 'navigation' COMMANDS.value?(input) when 'complexity' LEVELS.value?(input) else false end end