Skip to content

nutrun-string

A couple of years ago a good friend published this simple yet useful gist which me and presumably other people have been using quite a bit. Every time I needed it, I just went over, copied the code and dropped it in my project, thinking ‘I really need to bundle this’.

So now I did, and you can use it too! An important caveat is that this gem will extend the native ruby String class which many people frown upon, but if you don’t mind, go right ahead and use it.

Here is a real quick usage example:

require 'rubygems'
require 'nutrun-string'
dashes = '==========================='
[:red, :magenta, :green, :yellow, :blue, :cyan, :white].map { |m| puts dashes.send(m) }
puts %[#{'PIMP'.red} #{'MY'.red} #{'CONSOLE'.green} #{'STRINGS'.yellow}, #{'YO'.cyan}]
[:red, :magenta, :green, :yellow, :blue, :cyan, :white].reverse.map { |m| puts dashes.send(m) }
sleep 5
clear_screen

Links

Code’s on github, and this is George’s original blog post introducing the code.

Comment Feed

No Responses (yet)



Some HTML is OK

or, reply to this post via trackback.