Sha256: e78ef386633c17cbdb29178aacc691987c7aa912b665fc3ec32bbdcd818f49e7

Contents?: true

Size: 1.06 KB

Versions: 13

Compression:

Stored size: 1.06 KB

Contents

# Color overrides for terminal output (ref: https://stackoverflow.com/a/16363159)

class String
  def black;          "\e[30m#{self}\e[0m" end
  def red;            "\e[31m#{self}\e[0m" end
  def green;          "\e[32m#{self}\e[0m" end
  def brown;          "\e[33m#{self}\e[0m" end
  def blue;           "\e[34m#{self}\e[0m" end
  def magenta;        "\e[35m#{self}\e[0m" end
  def cyan;           "\e[36m#{self}\e[0m" end
  def gray;           "\e[37m#{self}\e[0m" end

  def bg_black;       "\e[40m#{self}\e[0m" end
  def bg_red;         "\e[41m#{self}\e[0m" end
  def bg_green;       "\e[42m#{self}\e[0m" end
  def bg_brown;       "\e[43m#{self}\e[0m" end
  def bg_blue;        "\e[44m#{self}\e[0m" end
  def bg_magenta;     "\e[45m#{self}\e[0m" end
  def bg_cyan;        "\e[46m#{self}\e[0m" end
  def bg_gray;        "\e[47m#{self}\e[0m" end

  def bold;           "\e[1m#{self}\e[22m" end
  def italic;         "\e[3m#{self}\e[23m" end
  def underline;      "\e[4m#{self}\e[24m" end
  def blink;          "\e[5m#{self}\e[25m" end
  def reverse_color;  "\e[7m#{self}\e[27m" end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
papa-1.2.0 lib/papa/string.rb
papa-1.1.0 lib/papa/string.rb
papa-1.0.0 lib/papa/string.rb
papa-0.7.2 lib/papa/string.rb
papa-0.7.1 lib/papa/string.rb
papa-0.7.0 lib/papa/string.rb
papa-0.6.2 lib/papa/string.rb
papa-0.6.1 lib/papa/string.rb
papa-0.6.0 lib/papa/string.rb
papa-0.5.0 lib/papa/string.rb
papa-0.4.1 lib/papa/string.rb
papa-0.4.0 lib/papa/string.rb
papa-0.3.0 lib/papa/string.rb