Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/rubocop_plus/core_ext/string.rb
Overview
Add some ome simple colorization methods for formatting console output. Prefix methods with rs_ so they don’t collide with other gems.
Class Attribute Summary collapse
-
.allow_color ⇒ Object
Returns the value of attribute allow_color.
Instance Method Summary collapse
Class Attribute Details
.allow_color ⇒ Object
Returns the value of attribute allow_color.
5 6 7 |
# File 'lib/rubocop_plus/core_ext/string.rb', line 5 def allow_color @allow_color end |
Instance Method Details
#rubo_colorize(color_code) ⇒ Object
8 9 10 |
# File 'lib/rubocop_plus/core_ext/string.rb', line 8 def rubo_colorize(color_code) String.allow_color ? "\e[#{color_code}m#{self}\e[0m" : self end |
#rubo_green ⇒ Object
16 17 18 |
# File 'lib/rubocop_plus/core_ext/string.rb', line 16 def rubo_green rubo_colorize(32) end |
#rubo_red ⇒ Object
12 13 14 |
# File 'lib/rubocop_plus/core_ext/string.rb', line 12 def rubo_red rubo_colorize(31) end |
#rubo_yellow ⇒ Object
20 21 22 |
# File 'lib/rubocop_plus/core_ext/string.rb', line 20 def rubo_yellow rubo_colorize(33) end |