Created
December 26, 2008 19:49
-
-
Save marcric/40115 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_from_user_input | |
puts "Please insert a year to see if it's a Leap year: " | |
STDOUT.flush | |
gets.chomp | |
end | |
def validator(a_string) | |
if(x=(a_string.scan(/\D/).size==0)) | |
puts "numeric" | |
puts a_string | |
exit | |
else | |
puts"non-numeric" | |
end | |
end | |
def iterator | |
validated=case | |
when validator(read_from_user_input).nil? then read_from_user_input | |
else | |
puts"after while" | |
return validator(read_from_user_input).to_i | |
end | |
end | |
iterator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment