Class: IRC::Util::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/irc/util/color.rb

Constant Summary collapse

NORMAL =
"\x0f"
BOLD =
"\x02"
UNDERLINE =
"\x1f"
REVERSE =
"\x16"
WHITE =
"\x030"
BLACK =
"\x031"
DARK_BLUE =
"\x032"
DARK_GREEN =
"\x033"
RED =
"\x034"
BROWN =
"\x035"
PURPLE =
"\x036"
OLIVE =
"\x037"
YELLOW =
"\x038"
GREEN =
"\x039"
TEAL =
"\x0310"
CYAN =
"\x0311"
BLUE =
"\x0312"
MAGENTA =
"\x0313"
DARK_GRAY =
"\x0314"
LIGHT_GRAY =
"\x0315"
REGEXP_COLORS =
Regexp.new("\x03(\\d\\d?(,\\d\\d?)?)?")
REGEXP_FORMATTING =
Regexp.new("#{NORMAL}|#{BOLD}|#{UNDERLINE}|#{REVERSE}")

Class Method Summary collapse

Class Method Details

.remove_color(str) ⇒ Object

Removes all IRC color characters from the given string.



59
60
61
# File 'lib/irc/util/color.rb', line 59

def self.remove_color(str)
  return str.gsub(REGEXP_COLORS, '')
end

.remove_color_and_formatting(str) ⇒ Object

Removes all IRC color and formatting characters from the given string.



64
65
66
# File 'lib/irc/util/color.rb', line 64

def self.remove_color_and_formatting(str)
  return remove_color(remove_formatting(str))
end

.remove_formatting(str) ⇒ Object

Removes all IRC formatting characters from the given string.



69
70
71
# File 'lib/irc/util/color.rb', line 69

def self.remove_formatting(str)
  return str.gsub(REGEXP_FORMATTING, '')
end