I have a function that is suppose to force user to enter the values from yes/no/y/n. If user enter any other value then it should prompt the user for INVALID ENTRY message but it is not handling the else block as expected. Can someone let me know what's going wrong here?
def handleYesNo(value)
begin
val = ""
while("#{value}" != "")
if ("#{value.downcase}" == "yes" || "#{value.downcase}" == "y" || "#{value.downcase}" == "no" || "#{value.downcase}" == "n")
val = value
break
else
puts "INVALID ENTRY"
end
end
val
rescue => e
puts "Exception occurred - #{e}.".red
end
end