Class: Test::Color
- Inherits:
-
Object
- Object
- Test::Color
- Defined in:
- lib/test-unit-ext/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.
5 6 7 8 9 10 11 12 13 |
# File 'lib/test-unit-ext/color.rb', line 5 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
35 36 37 |
# File 'lib/test-unit-ext/color.rb', line 35 def +(other) MixColor.new([self, other]) end |
#escape_sequence ⇒ Object
31 32 33 |
# File 'lib/test-unit-ext/color.rb', line 31 def escape_sequence "\e[#{sequence.join(';')}m" end |
#sequence ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/test-unit-ext/color.rb', line 15 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 |