Method: Autumn::Formatting::Mirc#color
- Defined in:
- lib/autumn/formatting.rb
#color(fgcolor, bgcolor = nil, options = {}) ⇒ Object
Colors the following text with a foreground and background color. Colors are a symbol in the COLORS hash. By default the background is left uncolored. This method returns a string that should be prepended to the text you want to colorize. Append an UNCOLOR token when you wish to end colorization.
Because of limitations in the mIRC color-coding system, a space will be added after the color code (and before any colorized text). Without this space character, it is possible that your text will appear in the wrong color. (This is most likely to happen when colorizing numbers with commas in them, such as “1,160”.) If you would like to suppress this space, because you either are sure that your text will be formatted correctly anyway, or you simply don’t care, you can pass :suppress_space => true to this method.
105 106 107 108 109 |
# File 'lib/autumn/formatting.rb', line 105 def color(fgcolor, bgcolor=nil, ={}) fgcolor = :black unless COLORS.include? fgcolor bgcolor = :white unless (bgcolor.nil? or COLORS.include? bgcolor) "#{COLOR_CODE}#{COLORS[fgcolor]}#{bgcolor ? (',' + COLORS[bgcolor]) : ''}#{options[:suppress_space] ? '' : ' '}" end |