5 Protocols.each {|protocol| protocol::initialize }
10 # To be inherited from for any +Protocol+. A +Rat+ +Protocol+ must expose at
11 # least four things - an +::initialize+ method, a +::new+ (+#initialize+, in
12 # other words) method, a +::terminate+ method, and a +#<<+ method.
14 def self.inherited klass
18 # One of the required methods in a +Protocol+ plugin, +::initialize+ is
19 # run when +Rat+ starts (if there is a default connection set up involving
20 # your protocol), when the first window is created for a protocol, or when the
21 # protocol is otherwise initialized by +Rat+. It's perfect to
22 # make any connections, declare presence, and so on. It will only be run
23 # once, unless +::terminate+ is run and then the protocol is re-connected.
25 # This should take a login argument, and optionally a password argument
26 # (if relevant), and should eventually call `super`.
27 def self.initialize # login, password = nil
28 Protocol::Initialized << self
31 # Provided by +Base+, and probably doesn't need to be modified - this
32 # predicate will determine if your protocol has been globally initialized
35 Protocol.initialized.include? self
38 # Required for every protocol, this method is run when +Rat+ closes down
39 # itself, or, for some reason, closes the protocol.
41 # This should eventually call `super`.
43 Protocol.initialized.delete self
46 # The second required method, +::new+ (+#initialize+) is run when a window is
47 # dedicated to a protocol. Should accept a window object (where incoming
48 # messages or status information can be printed) and a target (that the user
49 # specified, where messages should be sent or whatever is appropriate).
51 # This should take window and target arguments, and eventually call
52 # +super+ with those arguments.
53 def initialize window, target
58 # Finally, a +#<<+ method that deals with outgoing messages, sending
59 # them on their merry way or processing them in some way.
61 # Should recieve a message argument, and can optionally call +super+ to
62 # simply print the target and message to the window.
64 @window << ['Rattagan', message].join(" > ")
68 # This class applies to any window with no protocol.
69 class None < Rat::Protocol::Base
79 def initialize window, target