Class: ModSpox::Handlers::Motd
- Defined in:
- lib/mod_spox/handlers/Motd.rb
Instance Method Summary collapse
-
#initialize(handlers) ⇒ Motd
constructor
A new instance of Motd.
- #process(string) ⇒ Object
Constructor Details
#initialize(handlers) ⇒ Motd
Returns a new instance of Motd.
4 5 6 7 8 9 10 |
# File 'lib/mod_spox/handlers/Motd.rb', line 4 def initialize(handlers) handlers[RPL_MOTDSTART] = self handlers[RPL_MOTD] = self handlers[RPL_ENDOFMOTD] = self @motds = Hash.new @raw = Hash.new end |
Instance Method Details
#process(string) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mod_spox/handlers/Motd.rb', line 11 def process(string) if(string =~ /^:(\S+) #{RPL_MOTDSTART.to_s}.*?:-\s?(\S+)/) @motds[$1] = Array.new @raw[$1] = [string] return elsif(string =~ /^:(\S+) #{RPL_MOTD.to_s}.*?:-\s?(.+)$/) @motds[$1] << $2 @raw[$1] << string return elsif(string =~ /^:(\S+) #{RPL_ENDOFMOTD.to_s}/) @raw[$1] << string = Messages::Incoming::Motd.new(@raw[$1].join("\n"), @motds[$1].join("\n"), $1) @motds.delete($1) @raw.delete($1) return end end |