Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/B4U/string_methods.rb
Class Attribute Summary collapse
-
.colour_enabled ⇒ Object
Returns the value of attribute colour_enabled.
Class Method Summary collapse
Instance Method Summary collapse
- #bg_green ⇒ Object
- #bold ⇒ Object
- #colorize(code) ⇒ Object
- #cyan ⇒ Object
- #green ⇒ Object
- #magenta ⇒ Object
- #red ⇒ Object
Class Attribute Details
.colour_enabled ⇒ Object
Returns the value of attribute colour_enabled.
3 4 5 |
# File 'lib/B4U/string_methods.rb', line 3 def colour_enabled @colour_enabled end |
Class Method Details
.disable_colour ⇒ Object
10 11 12 |
# File 'lib/B4U/string_methods.rb', line 10 def self.disable_colour self.colour_enabled = false end |
.enable_colour ⇒ Object
6 7 8 |
# File 'lib/B4U/string_methods.rb', line 6 def self.enable_colour self.colour_enabled = true end |
Instance Method Details
#bg_green ⇒ Object
28 |
# File 'lib/B4U/string_methods.rb', line 28 def bg_green = colorize(42) |
#bold ⇒ Object
30 |
# File 'lib/B4U/string_methods.rb', line 30 def bold = colorize(1) |
#colorize(code) ⇒ Object
14 15 16 17 18 |
# File 'lib/B4U/string_methods.rb', line 14 def colorize(code) return self unless String.colour_enabled "\e[#{code}m#{self}\e[0m" end |
#cyan ⇒ Object
26 |
# File 'lib/B4U/string_methods.rb', line 26 def cyan = colorize(36) |
#green ⇒ Object
22 |
# File 'lib/B4U/string_methods.rb', line 22 def green = colorize(32) |
#magenta ⇒ Object
24 |
# File 'lib/B4U/string_methods.rb', line 24 def magenta = colorize(35) |
#red ⇒ Object
20 |
# File 'lib/B4U/string_methods.rb', line 20 def red = colorize(31) |