Module: Regtest::Colors
- Included in:
- Regtest
- Defined in:
- lib/regtest/colors.rb
Class Attribute Summary collapse
-
.mapping ⇒ Object
Color mapping Examples: Regtest::Colors.mapping = :lightblue Regtest::Colors.mapping = :@red # ‘@’ prefix means background color Regtest::Colors.mapping = %i(cyan italic) # more than one color code is possible.
Class Method Summary collapse
-
.apply(str, *codes) ⇒ Object
Apply color codes to a string.
-
.codes ⇒ Object
Get available color codes.
Instance Method Summary collapse
-
#report(*args, type: nil) ⇒ Object
Redefine Regtest.report.
Class Attribute Details
.mapping ⇒ Object
23 24 25 |
# File 'lib/regtest/colors.rb', line 23 def mapping @mapping end |
Class Method Details
.apply(str, *codes) ⇒ Object
Apply color codes to a string
26 27 28 29 30 31 32 33 |
# File 'lib/regtest/colors.rb', line 26 def apply str, *codes codes.flatten.each do |c| num = @codes[c.to_sym] fail format('Code %s not supported.', c) unless num str = format("\e[%dm%s", num, str) end format("%s\e[0m", str) end |
.codes ⇒ Object
Get available color codes
36 37 38 |
# File 'lib/regtest/colors.rb', line 36 def codes @codes.keys end |