Class: Circus::IRC
- Inherits:
-
Object
show all
- Defined in:
- lib/irc.rb
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ IRC
Returns a new instance of IRC.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/irc.rb', line 15
def initialize(options = {})
@default = { :server => "irc.freenode.net",
:port => 6667,
:nick => "Circus-IRC",
:username => "circus",
:realname => "Using ruby with Circus IRC",
:send_speed => 0.5,
:timeout => 15*60, :eol => "\r\n",
:debug => false }
@config = @default.merge options
@event_manager = EventManager.new
default_subscriptions
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/irc.rb', line 52
def method_missing(name, *args)
message_class = "Circus::Messages::#{name.to_s.downcase.classify}"
message_class = message_class.constantize
@connection.send message_class.new *args
rescue
super
end
|
Instance Method Details
#connect ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/irc.rb', line 32
def connect
@connection ||= Connection.new @event_manager, @config
pass @config[:password] if @config[:password]
nick @config[:nick]
user "#{@config[:username]} 0 * :#{@config[:realname]}"
@connection.connect
end
|
#subscribe(type, &block) ⇒ Object
42
43
44
|
# File 'lib/irc.rb', line 42
def subscribe(type, &block)
@event_manager.subscribe(type, &block)
end
|