Class: Enhanced::Colors
- Inherits:
-
Object
- Object
- Enhanced::Colors
- Defined in:
- lib/enhanced/colors.rb
Constant Summary collapse
- COLORS =
{ red: 31, green: 32, yellow: 33, blue: 34, purple: 35, cyan: 36, white: 0 }.freeze
- RESET_CODE =
"\e[0m".freeze
Class Method Summary collapse
Class Method Details
.code(num) ⇒ Object
20 21 22 |
# File 'lib/enhanced/colors.rb', line 20 def code(num) "\e[#{num}m".freeze end |
.color(num, string) ⇒ Object
15 16 17 18 |
# File 'lib/enhanced/colors.rb', line 15 def color(num, string) return string unless @enabled "#{code(num)}#{string}#{RESET_CODE}" end |
.enabled=(value) ⇒ Object
11 12 13 |
# File 'lib/enhanced/colors.rb', line 11 def enabled=(value) @enabled = value end |
.enabled? ⇒ Boolean
7 8 9 |
# File 'lib/enhanced/colors.rb', line 7 def enabled? @enabled end |