Module: IRCParser::Helper

Extended by:
Helper
Included in:
Helper
Defined in:
lib/irc_parser/helper.rb

Defined Under Namespace

Modules: Channel, NicknameHelpers

Constant Summary collapse

STATS_MODES =

tools.ietf.org/html/rfc1459#section-4.3.2 c - returns a list of servers which the server may connect to or allow connections from; h - returns a list of servers which are either forced to be treated as leaves or allowed to act as hubs; i - returns a list of hosts which the server allows a client to connect from; k - returns a list of banned username/hostname combinations for that server; l - returns a list of the server’s connections, showing how long each connection has been established and the traffic

over that connection in bytes and messages for each direction;

m - returns a list of commands supported by the server and the usage count for each if the usage count is non zero; o - returns a list of hosts from which normal clients may become operators; y - show Y (Class) lines from server’s configuration file; u - returns a string showing how long the server has been up.

%w|c h i k l m o y u|
NICK_REGEXP =
/^[a-zA-Z]+[a-zA-Z0-9]*/
CHANNEL_PREFIXES =
{
  :normal   => "#",
  :local    => "&",
  :modeless => "+",
  :safe     => "!"
}
CHANNEL_REGEXP =
/^[#{CHANNEL_PREFIXES.values.join("|")}][a-zA-Z0-9]+/

Instance Method Summary collapse

Instance Method Details

#invalid_channel_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/irc_parser/helper.rb', line 55

def invalid_channel_name?(name)
  not valid_channel_name?(name)
end

#invalid_nick?(nick) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/irc_parser/helper.rb', line 32

def invalid_nick?(nick)
  not valid_nick?(nick)
end

#parse_regexp(text) ⇒ Object



9
10
11
# File 'lib/irc_parser/helper.rb', line 9

def parse_regexp(text)
  /#{ text.to_s.split(".").join("\\.").gsub(/\*|\?/, ".*") }/
end

#underscore(string) ⇒ Object



5
6
7
# File 'lib/irc_parser/helper.rb', line 5

def underscore(string)
  string.to_s.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
end

#valid_channel_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/irc_parser/helper.rb', line 51

def valid_channel_name?(name)
  name.to_s =~ CHANNEL_REGEXP
end

#valid_nick?(nick) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/irc_parser/helper.rb', line 28

def valid_nick?(nick)
  nick =~ NICK_REGEXP
end