Confirm name input using include? method

The following memorandum

def check_name(str) 
  if str.include?(".")
    puts "!error!Symbols cannot be registered"
  elsif str.include?(" ")
    puts "!error!Blanks cannot be registered"
  else
    puts "Registration has been completed"
  end
end

puts "Please enter the name you want to register(Example)YamadaTaro"
str = gets
check_name(str) 

In the check_name method, the if statement is used to perform a conditional branch that "registers if there is no period or space, and issues an error if there is a period or space". Use the include? Method for the character string received by the argument str, and add "." (Period). Judge whether there is a "" (blank).

Recommended Posts

Confirm name input using include? method
include method
Training using each_with_index method
Try using each_with_index method
Create a name input function