module Net::IRC

Constants

VERSION

Public Class Methods

ctcp_decode(str) click to toggle source

Decode from CTCP message delimited with x01.

# File lib/net/irc.rb, line 49
def ctcp_decode(str)
        ctcp_dequote(str.delete("\x01"))
end
ctcp_dequote(str) click to toggle source
# File lib/net/irc.rb, line 60
def ctcp_dequote(str)
        low_dequote(str).gsub("\\a", "\x01").gsub(/\(.|\z)/m, "\\1")
end
ctcp_encode(str) click to toggle source

Encode to CTCP message. Prefix and postfix x01.

# File lib/net/irc.rb, line 42
def ctcp_encode(str)
        "\x01#{ctcp_quote(str)}\x01"
end
ctcp_quote(str) click to toggle source
# File lib/net/irc.rb, line 55
def ctcp_quote(str)
        low_quote(str.gsub("\\", "\\\\\\\\").gsub("\x01", "\\a"))
end

Private Instance Methods

ctcp_decode(str) click to toggle source

Decode from CTCP message delimited with x01.

# File lib/net/irc.rb, line 49
def ctcp_decode(str)
        ctcp_dequote(str.delete("\x01"))
end
ctcp_dequote(str) click to toggle source
# File lib/net/irc.rb, line 60
def ctcp_dequote(str)
        low_dequote(str).gsub("\\a", "\x01").gsub(/\(.|\z)/m, "\\1")
end
ctcp_encode(str) click to toggle source

Encode to CTCP message. Prefix and postfix x01.

# File lib/net/irc.rb, line 42
def ctcp_encode(str)
        "\x01#{ctcp_quote(str)}\x01"
end
ctcp_quote(str) click to toggle source
# File lib/net/irc.rb, line 55
def ctcp_quote(str)
        low_quote(str.gsub("\\", "\\\\\\\\").gsub("\x01", "\\a"))
end
low_dequote(str) click to toggle source
# File lib/net/irc.rb, line 70
def low_dequote(str)
        str.gsub("\x10n", "\n").gsub("\x10r", "\r").gsub("\x10\x30", "\x00").gsub("\x10\x10", "\x10")
end
low_quote(str) click to toggle source
# File lib/net/irc.rb, line 66
def low_quote(str)
        str.gsub("\x10", "\x10\x10").gsub("\x00", "\x10\x30").gsub("\r", "\x10r").gsub("\n", "\x10n")
end