Last active
December 3, 2016 04:39
-
-
Save NigelThorne/429b4fca6cf1a24fe368bfcb98a5c490 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 has_arg(arg) | |
ARGV.include? arg | |
end | |
text = ARGV[0] | |
lines = text.scan(/.{0,40}(?:\b|$)/).map{|l| l.strip } | |
lines = (lines[-1] == "" ? lines[0...-1] : lines) | |
longest = lines.map{|l| l.length}.max | |
lines.map!{|l| l+ (" " * (longest - l.length))} | |
def bubble(lines) | |
if (lines.count == 1) | |
if has_arg("--think") | |
"( #{lines[0]} )" | |
else | |
"< #{lines[0]} >" | |
end | |
else | |
borders = [ "/ $ \\", | |
"| $ |", | |
"\\ $ /"] | |
count = lines.count | |
lines.each.with_index.map{|line, index| | |
format = (index == count-1 ? 2 : (index == 0 ? 0 : 1) ) | |
borders[format].gsub("$", line) | |
}.join("\n") | |
end | |
end | |
def eyes(args = ARGV) | |
moods = { | |
"--mad" => "oO", | |
"--wink" => "o-", | |
"--squint" => "><", | |
"--sleep" => "--", | |
"--dead" => "XX", | |
"--alarm" => "OO" | |
} | |
args.reverse.each{|arg| return moods[arg] if moods.has_key?(arg) } | |
"oo" | |
end | |
tongue = " " | |
tongue = "U" if has_arg "--mad" | |
link = "\\" | |
link = "o" if has_arg "--think" | |
puts """ #{ '_' * (longest+2)} | |
#{bubble lines} | |
#{ '-' * (longest+2)} | |
#{link} ^__^ | |
#{link} (#{eyes})\\_______ | |
(__)\\ )\\/\\ | |
#{tongue} ||----w | | |
|| ||""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: