Class: Treefell::Color
- Inherits:
-
Object
- Object
- Treefell::Color
- Defined in:
- lib/treefell/color.rb
Constant Summary collapse
- COLORS =
[ :bright_black, :bright_blue, :bright_cyan, :bright_green, :bright_magenta, :bright_red, :bright_yellow ]
Class Method Summary collapse
Instance Method Summary collapse
- #colorize(str) ⇒ Object
-
#initialize(color) ⇒ Color
constructor
A new instance of Color.
Constructor Details
#initialize(color) ⇒ Color
20 21 22 |
# File 'lib/treefell/color.rb', line 20 def initialize(color) @color = color end |
Class Method Details
.rotate ⇒ Object
13 14 15 16 17 18 |
# File 'lib/treefell/color.rb', line 13 def self.rotate if !@colors_index || @colors_index == COLORS.length - 1 @colors_index = -1 end new(COLORS[@colors_index+=1]) end |
Instance Method Details
#colorize(str) ⇒ Object
24 25 26 |
# File 'lib/treefell/color.rb', line 24 def colorize(str) ::Term::ANSIColor.send(@color, str) end |