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
Methods inherited from Handler
Constructor Details
#initialize(handlers) ⇒ Motd
Returns a new instance of Motd.
5 6 7 8 9 10 11 |
# File 'lib/mod_spox/handlers/Motd.rb', line 5 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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mod_spox/handlers/Motd.rb', line 12 def process(string) if(string =~ /^:(\S+) #{RPL_MOTDSTART.to_s}.*?:-\s?(\S+)/) @motds[$1] = Array.new @raw[$1] = [string] return nil elsif(string =~ /^:(\S+) #{RPL_MOTD.to_s}.*?:-\s?(.+)$/) @motds[$1] ||= [] @raw[$1] ||= [] @motds[$1] << $2 @raw[$1] << string return nil elsif(string =~ /^:(\S+) #{RPL_ENDOFMOTD.to_s}/) @raw[$1] ||= [] @motds[$1] ||= [] @raw[$1] << string = Messages::Incoming::Motd.new(@raw[$1].join("\n"), @motds[$1].join("\n"), $1) @motds.delete($1) @raw.delete($1) return else return nil end end |