Class: Test::Unit::Color
- Inherits:
-
Object
- Object
- Test::Unit::Color
- Defined in:
- lib/test/unit/color.rb
Constant Summary collapse
- NAMES =
["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"]
Instance Method Summary collapse
- #+(other) ⇒ Object
- #escape_sequence ⇒ Object
-
#initialize(name, options = {}) ⇒ Color
constructor
A new instance of Color.
- #sequence ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Color
Returns a new instance of Color.
6 7 8 9 10 11 12 13 14 |
# File 'lib/test/unit/color.rb', line 6 def initialize(name, ={}) @name = name @foreground = [:foreground] @foreground = true if @foreground.nil? @intensity = [:intensity] @bold = [:bold] @italic = [:italic] @underline = [:underline] end |
Instance Method Details
#+(other) ⇒ Object
36 37 38 |
# File 'lib/test/unit/color.rb', line 36 def +(other) MixColor.new([self, other]) end |
#escape_sequence ⇒ Object
32 33 34 |
# File 'lib/test/unit/color.rb', line 32 def escape_sequence "\e[#{sequence.join(';')}m" end |
#sequence ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/test/unit/color.rb', line 16 def sequence sequence = [] if @name == "none" elsif @name == "reset" sequence << "0" else foreground_parameter = @foreground ? 3 : 4 foreground_parameter += 6 if @intensity sequence << "#{foreground_parameter}#{NAMES.index(@name)}" end sequence << "1" if @bold sequence << "3" if @italic sequence << "4" if @underline sequence end |