Class: Net::IRC::Message::ServerConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/net/irc/message/serverconfig.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServerConfig

Returns a new instance of ServerConfig.



4
5
6
7
# File 'lib/net/irc/message/serverconfig.rb', line 4

def initialize
  @config = {}
  @mode_parser = Net::IRC::Message::ModeParser.new
end

Instance Attribute Details

#mode_parserObject (readonly)

Returns the value of attribute mode_parser.



2
3
4
# File 'lib/net/irc/message/serverconfig.rb', line 2

def mode_parser
  @mode_parser
end

Instance Method Details

#[](key) ⇒ Object



27
28
29
# File 'lib/net/irc/message/serverconfig.rb', line 27

def [](key)
  @config[key]
end

#set(arg) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/net/irc/message/serverconfig.rb', line 9

def set(arg)
  params = arg.kind_of?(Net::IRC::Message) ? arg.to_a : arg.split(" ")

  params[1..-1].each do |s|
    case s
    when /\A:?are supported by this server\z/
      # Ignore
    when /\A([^=]+)=(.*)\z/
      key = Regexp.last_match[1].to_sym
      value = Regexp.last_match[2]
      @config[key] = value
      @mode_parser.set(key, value) if key == :CHANMODES || key == :PREFIX
    else
      @config[s] = true
    end
  end
end