Implemeting if statement to case

Hello, i just starting to learning code, and just making this little
program to learn from my own mistakes. Basically it is code for
registration and it works, more less, but i want to implement more
possibilities into it. Thank you for your time if you could help me
understand how basically implement second code into first and how it is
done that i would gain future knowledge on how ruby programming works.

First code.
id_pass_list = {
du_trys: 123456,
trys_keturi: 54321
puts “Would you like to register on our site? type only yes or no”
answer = gets.chomp
answer = answer.downcase

case answer
when “yes”
puts "Please type your user name: "
id = gets.chomp
id_length = id.length
#i would imagine that second code should go here
#if id_lenght >= 3
#puts “Your id is too short!”
#elsif id_lenght <= 10
#puts “Your id is too long!”
#puts “Continue”

puts "Please type your password: "
pass = gets.chomp
id_pass_list[id.to_sym] = pass.to_i
puts “You have been registered #{id} #{pass}”

when “no”
puts “Enjoy our site!”

second code.
puts “Please enter your id”
id = gets.chomp
id_length = answer.length

if x <= 2
puts “You need longer id!”
elsif x >= 10
puts “You need shorter id!”
puts “Your id is #{id}!”

P.s. Sorry for messy code