Module: Validate

Included in:
NewSuperCodebreaker2021::Game
Defined in:
lib/validate.rb

Instance Method Summary collapse

Instance Method Details

#check_input(input, command_list) ⇒ Object


19
20
21
22
23
24
# File 'lib/validate.rb', line 19

def check_input(input, command_list)
  if input.to_i.zero? && command_list.include?(input.to_sym)
    input.to_sym
  else false
  end
end

#validate_name(name) ⇒ Object


2
3
4
5
6
7
8
# File 'lib/validate.rb', line 2

def validate_name(name)
  if name.length >= 3 && name.length <= 20
    name
  else
    false
  end
end

#validate_user_code(us_code) ⇒ Object


10
11
12
13
14
15
16
17
# File 'lib/validate.rb', line 10

def validate_user_code(us_code)
  arr_code = check_splitting(us_code)
  if valid_number?(arr_code)
    arr_code
  else
    false
  end
end