10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# 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
|