Sha256: 7a40f919be7300b8f0a8caab7e15faf4c0a3e55c8d37ef8760ed901b7b03b297

Contents?: true

Size: 1.63 KB

Versions: 5

Compression:

Stored size: 1.63 KB

Contents

#  ======================================================
#  String Class
#  ======================================================
class String
  #  ----------------------------------------------------
  #  colorize method
  #
  #  Outputs a string in a formatted color.
  #  @param color_code The code to use
  #  @return Void
  #  ----------------------------------------------------
  def colorize(color_code)
    "\e[#{ color_code }m#{ self }\e[0m"
  end

  #  ----------------------------------------------------
  #  blue method
  #
  #  Convenience method to output a blue string
  #  @return Void
  #  ----------------------------------------------------
  def blue
    colorize(34)
  end

  #  ----------------------------------------------------
  #  green method
  #
  #  Convenience method to output a green string
  #  @return Void
  #  ----------------------------------------------------
  def green
    colorize(32)
  end

  #  ----------------------------------------------------
  #  purple method
  #
  #  Convenience method to output a purple string
  #  @return Void
  #  ----------------------------------------------------
  def purple
    colorize(35)
  end

  #  ----------------------------------------------------
  #  red method
  #
  #  Convenience method to output a red string
  #  @return Void
  #  ----------------------------------------------------
  def red
    colorize(31)
  end

  #  ----------------------------------------------------
  #  yellow method
  #
  #  Convenience method to output a yellow string
  #  @return Void
  #  ----------------------------------------------------
  def yellow
    colorize(33)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sifttter-redux-0.4.6 lib/sifttter_redux/string_extensions.rb
sifttter-redux-0.4.4 lib/sifttter_redux/string_extensions.rb
sifttter-redux-0.4.3 lib/sifttter_redux/string_extensions.rb
sifttter-redux-0.4.2 lib/sifttter_redux/string_extensions.rb
sifttter-redux-0.4.1 lib/sifttter_redux/string_extensions.rb