Created
January 20, 2020 01:30
-
-
Save jonmoter/cb0b5bb0e6e9f835beeacf0278ed508f to your computer and use it in GitHub Desktop.
ruby script to generate your dragon name, based on the rules in some meme image
This file contains hidden or 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
#!/usr/bin/env ruby | |
# | |
# Generate a dragon name based on this meme: | |
# https://www.facebook.com/creepyshit01/photos/a.1037741526249418/2895913810432171 | |
# | |
# Usage: ./dragon_name [<first_name>] [<last_name>] [<mothers_name>] [<fathers_name>] | |
# | |
# If you don't pass in any of the names, you will be prompted for them. | |
def prompt_for(text_prompt, min_length = 2) | |
loop do | |
STDOUT.print text_prompt + ': ' | |
STDOUT.flush | |
input = gets.strip | |
return input if input.length >= min_length | |
puts "C'mon, you need to input SOMETHING..." | |
end | |
end | |
first_name = ARGV[0] || prompt_for("Enter your first name") | |
last_name = ARGV[1] || prompt_for("Enter your last name") | |
mom_name = ARGV[2] || prompt_for("Your mother's first name") | |
dad_name = ARGV[3] || prompt_for("Your dad's first name") | |
dragon_name = '' | |
dragon_name += first_name[-2, 2] | |
dragon_name += last_name[last_name.length / 2, 2] | |
dragon_name += mom_name[0, 2].downcase | |
dragon_name += dad_name[-1] | |
puts "" | |
puts "Your dragon name is #{dragon_name.capitalize}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment