Class: IRC::ServerConfigDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/on_irc/config.rb

Class Method Summary collapse

Class Method Details

.run(&block) ⇒ Object

Raises:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/on_irc/config.rb', line 40

def self.run(&block)
  confdsl = self.new
  block.arity < 1 ? confdsl.instance_eval(&block) : block.call(confdsl)

  raise ConfigError, 'no address' unless confdsl.address

  conf = ServerConfig.new

  conf.address = confdsl.address
  # If not supplied, the port defaults to 6667, or 6697 if ssl is used
  conf.port = confdsl.port || (confdsl.ssl? ? 6697 : 6667)
  conf.ssl = confdsl.ssl?
  conf.nick = confdsl.nick
  conf.ident = confdsl.ident
  conf.realname = confdsl.realname

  conf
end