puts "Enter the String for checking Character Length"
@character = gets.chomp
puts "Are you want to exclude spaces from the enterede string?(yes/no)"
@options = gets.chomp
if @options == "yes" or @options == "Yes"
@character = @character.gsub(" ", "")
puts "Are you want to change the case of a string?(upper/lower)"
@case_choice = gets.chomp
if @case_choice == "upper"
@character = @character.upcase
puts "@result ==== #{@character.inspect}"
@character = @character.length
puts "@character === #{@character.inspect}"
elsif @case_choice == "lower"
@character = @character.downcase
puts "@result ==== #{@character.inspect}"
@character = @character.length
puts "@character === #{@character.inspect}"
else
puts "Please enter valid options"
end
elsif @options == "no" or @options == "No"
if @case_choice == "upper"
@character = @character.upcase
puts "@result ==== #{@character.inspect}"
@character = @character.length
puts "@character === #{@character.inspect}"
elsif @case_choice == "lower"
@character = @character.downcase
puts "@result ==== #{@character.inspect}"
@character = @character.length
puts "@character === #{@character.inspect}"
else
puts "Please enter valid options"
end
else
puts "Please enter valid options"
end
If the user enters the wrong option?then it goes to the inital stage. For example if the user enters 'jhgh' instead of 'Yes' means it should be go to inital stage. How can i done this?