File: serverconfig.rb

package info (click to toggle)
ruby-net-irc 0.0.9-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 408 kB
  • sloc: ruby: 7,268; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 616 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class Net::IRC::Message::ServerConfig
	attr_reader :mode_parser

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

	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

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