Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/B4U/string_methods.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.colour_enabledObject

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_colourObject



10
11
12
# File 'lib/B4U/string_methods.rb', line 10

def self.disable_colour
  self.colour_enabled = false
end

.enable_colourObject



6
7
8
# File 'lib/B4U/string_methods.rb', line 6

def self.enable_colour
  self.colour_enabled = true
end

Instance Method Details

#bg_greenObject



28
# File 'lib/B4U/string_methods.rb', line 28

def bg_green = colorize(42)

#boldObject



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

#cyanObject



26
# File 'lib/B4U/string_methods.rb', line 26

def cyan = colorize(36)

#greenObject



22
# File 'lib/B4U/string_methods.rb', line 22

def green = colorize(32)

#magentaObject



24
# File 'lib/B4U/string_methods.rb', line 24

def magenta = colorize(35)

#redObject



20
# File 'lib/B4U/string_methods.rb', line 20

def red = colorize(31)