Skip to content

Instantly share code, notes, and snippets.

@myobie
Created May 14, 2013 06:04
Show Gist options
  • Save myobie/5574016 to your computer and use it in GitHub Desktop.
Save myobie/5574016 to your computer and use it in GitHub Desktop.
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