Class: Treefell::Color

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(color) ⇒ Color

Returns a new instance of Color.



20
21
22
# File 'lib/treefell/color.rb', line 20

def initialize(color)
  @color = color
end

Class Method Details

.rotateObject



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