Sha256: 91253f5b48c11a09322f248c14dd1ad7adc06775a0b0a53d1b94632386f5a068

Contents?: true

Size: 863 Bytes

Versions: 11

Compression:

Stored size: 863 Bytes

Contents

#  String Class extensions
class String

  # Outputs a string in a formatted color.
  # @param [<Integer, String>] color_code The code to use
  # @return [void]
  def colorize(color_code)
    "\033[#{ color_code }m#{ self }\033[0m"
  end
  
  # Makes the associated string blue.
  # @return [void]
  def blue; colorize(34) end

  # Makes the associated string cyan.
  # @return [void]
  def cyan; colorize(36) end

  # Makes the associated string green.
  # @return [void]
  def green; colorize(32) end

  # Makes the associated string purple.
  # @return [void]
  def purple; colorize(35) end

  # Makes the associated string red.
  # @return [void]
  def red; colorize(31) end

  # Makes the associated string white.
  # @return [void]
  def white; colorize(37) end

  # Makes the associated string yellow.
  # @return [void]
  def yellow; colorize(33) end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cliutils-1.2.3 lib/cliutils/ext/String+Extensions.rb
cliutils-1.2.2 lib/cliutils/ext/String+Extensions.rb
cliutils-1.2.1 lib/cliutils/ext/String+Extensions.rb
cliutils-1.2.0 lib/cliutils/ext/String+Extensions.rb
cliutils-1.1.1 lib/cliutils/ext/String+Extensions.rb
cliutils-1.1.0 lib/cliutils/ext/String+Extensions.rb
cliutils-1.0.7 lib/cliutils/ext/String+Extensions.rb
cliutils-1.0.6 lib/cliutils/ext/String+Extensions.rb
cliutils-1.0.5 lib/cliutils/ext/String+Extensions.rb
cliutils-1.0.4 lib/cliutils/ext/String+Extensions.rb
cliutils-1.0.3 lib/cliutils/ext/String+Extensions.rb