Module: Net::IRC::PATTERN

Defined in:
lib/net/irc/pattern.rb

Overview

:nodoc:

Constant Summary collapse

LETTER =

letter = %x41-5A / %x61-7A ; A-Z / a-z digit = %x30-39 ; 0-9 hexdigit = digit / "A" / "B" / "C" / "D" / "E" / "F" special = %x5B-60 / %x7B-7D ; "[", "]", "", "`", "_", "^", ""|", ""

'A-Za-z'
DIGIT =
'0-9'
HEXDIGIT =
"#{DIGIT}A-Fa-f"
SPECIAL =
'\x5B-\x60\x7B-\x7D'
SHORTNAME =

shortname = ( letter / digit ) *( letter / digit / "-" ) *( letter / digit ) ; as specified in RFC 1123 [HNAME] hostname = shortname *( "." shortname )

"[#{LETTER}#{DIGIT}](?:[-#{LETTER}#{DIGIT}]*[#{LETTER}#{DIGIT}])?"
HOSTNAME =
"#{SHORTNAME}(?:\\.#{SHORTNAME})*"
SERVERNAME =

servername = hostname

HOSTNAME
NICKNAME =

nickname = ( letter / special ) 8( letter / digit / special / "-" ) NICKNAME = "[#LETTER#SPECIAL#DIGIT_][-#LETTER#DIGIT#SPECIAL]"

"\\S+"
USER =

user = 1*( %x01-09 / %x0B-0C / %x0E-1F / %x21-3F / %x41-FF ) ; any octet except NUL, CR, LF, " " and "@"

'[\x01-\x09\x0B-\x0C\x0E-\x1F\x21-\x3F\x41-\xFF]+'
IP4ADDR =

ip4addr = 13digit "." 13digit "." 13digit "." 13digit

"[#{DIGIT}]{1,3}(?:\\.[#{DIGIT}]{1,3}){3}"
IP6ADDR =

ip6addr = 1hexdigit 7( ":" 1hexdigit ) ip6addr =/ "0:0:0:0:0:" ( "0" / "FFFF" ) ":" ip4addr

"(?:[#{HEXDIGIT}]+(?::[#{HEXDIGIT}]+){7}|0:0:0:0:0:(?:0|FFFF):#{IP4ADDR})"
HOSTADDR =

hostaddr = ip4addr / ip6addr

"(?:#{IP4ADDR}|#{IP6ADDR})"
HOST =

host = hostname / hostaddr

"(?:#{HOSTNAME}|#{HOSTADDR})"
PREFIX =

prefix = servername / ( nickname [ [ "!" user ] "@" host ] )

"(?:#{NICKNAME}(?:(?:!#{USER})?@#{HOST})?|#{SERVERNAME})"
NOSPCRLFCL =

nospcrlfcl = %x01-09 / %x0B-0C / %x0E-1F / %x21-39 / %x3B-FF ; any octet except NUL, CR, LF, " " and ":"

'\x01-\x09\x0B-\x0C\x0E-\x1F\x21-\x39\x3B-\xFF'
COMMAND =

command = 1*letter / 3digit

"(?:[#{LETTER}]+|[#{DIGIT}]{3})"
MIDDLE =

SPACE = %x20 ; space character middle = nospcrlfcl *( ":" / nospcrlfcl ) trailing = *( ":" / " " / nospcrlfcl ) params = *14( SPACE middle ) [ SPACE ":" trailing ] =/ 14( SPACE middle ) [ SPACE [ ":" ] trailing ]

"[#{NOSPCRLFCL}][:#{NOSPCRLFCL}]*"
TRAILING =
"[: #{NOSPCRLFCL}]*"
PARAMS =
"(?:((?: #{MIDDLE}){0,14})(?: :(#{TRAILING}))?|((?: #{MIDDLE}){14}):?(#{TRAILING}))"
CRLF =

crlf = %x0D %x0A ; "carriage return" "linefeed" message = [ ":" prefix SPACE ] command [ params ] crlf

'\x0D\x0A'
MESSAGE =
"(?::(#{PREFIX}) )?(#{COMMAND})#{PARAMS}\s*#{CRLF}"
CLIENT_PATTERN =
/\A#{NICKNAME}(?:(?:!#{USER})?@#{HOST})\z/on
MESSAGE_PATTERN =
/\A#{MESSAGE}\z/on