I have the bad habit of always using puts
when I probably use print
. As a a result, I was having trouble with the gems that were usable for colorizing my ToDo 3.0. I figured out a gem-free solution, using ANSI escape codes, and thought I'd share.
WARNING: don't be surprised if someone comes along and tells you this is the worst thing you could ever do. I have NO idea if it is a kosher solution, but it worked and it required VERY little change to my code. Additionally, this method works on the systems we have at DBC (and on mine) but I don't know if it is universal (I "think" it is).
A little set-up: I decided that I wanted to handle the color coding of priorities(and the keeping of the priorities) in my Todo class and not my TodoList class. Each todo keeps track of its own priority level, so I just modified the to_s method to include the color.
ANSI escape codes are used to send things to the output that aren't printed, not unlike the \
before the n
of a new line. I'll show my code and then explai