Created
May 14, 2013 06:04
-
-
Save myobie/5574016 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
require 'term/ansicolor' | |
module Awesomeness | |
def self.included(base) | |
base.extend ClassMethods | |
base.send :include, Term::ANSIColor | |
end | |
def format_message(message) | |
whitelist = %w(red green yellow black blue magenta cyan white dark underscore blink negative concealed) | |
message.gsub(/%([a-z]+)%{([^}]+)}/) { | |
if whitelist.include?($1) | |
send($1, $2) | |
else | |
$2 | |
end | |
} | |
end | |
end | |
__END__ | |
format_message "Yo %blink%{Nathan}!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment