class String

Add color to strings

Public Instance Methods

bold() click to toggle source

Makes a string bold

Example

# Use on a String
'Hello, world!'.bold
# File lib/magic_conch_shell/colorize.rb, line 69
def bold
  "\e[1m#{self}\e[22m"
end
bright_white() click to toggle source

Colors a string in Bright White (15)

Example

# Use on a String
'Hello, world!'.bright_white
# File lib/magic_conch_shell/colorize.rb, line 56
def bright_white
  "\e[2;37m#{self}\e[0m"
end
color_randomize!() click to toggle source

Colorizes every single character randomly in a string

Example

# Use on a String
'Hello, world!'.color_randomize

# File lib/magic_conch_shell/colorize.rb, line 15
def color_randomize!
  chars.map! do |chr|
    "\e[#{rand(31..37)}m#{chr}\e[0m"
  end
end
green() click to toggle source

Colors a string in Green (2)

Example

# Use on a String
'Hello, world!'.bright_white
# File lib/magic_conch_shell/colorize.rb, line 30
def green
  "\e[32m#{self}\e[0m"
end
red() click to toggle source

Colors a string in Red (1)

Example

# Use on a String
'Hello, world!'.bright_white
# File lib/magic_conch_shell/colorize.rb, line 43
def red
  "\e[31m#{self}\e[0m"
end