Class: ModSpox::Handlers::Topic
- Defined in:
- lib/mod_spox/handlers/Topic.rb
Instance Method Summary collapse
-
#initialize(handlers) ⇒ Topic
constructor
A new instance of Topic.
- #process(string) ⇒ Object
Constructor Details
#initialize(handlers) ⇒ Topic
Returns a new instance of Topic.
4 5 6 7 8 9 |
# File 'lib/mod_spox/handlers/Topic.rb', line 4 def initialize(handlers) handlers[RPL_TOPIC] = self handlers[RPL_NOTOPIC] = self handlers[RPL_TOPICINFO] = self @topics = Hash.new end |
Instance Method Details
#process(string) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mod_spox/handlers/Topic.rb', line 10 def process(string) if(string =~ /#{RPL_TOPIC}.+?(\S+)\s:(.+)$/) channel = find_model($1) return Messages::Incoming::Topic.new(string, channel, $2) elsif(string =~ /#{RPL_NOTOPIC}.+?(\S+)\s:/) channel = find_model($1) return Messages::Incoming::Topic.new(string, channel, nil) elsif(string =~ /#{RPL_TOPICINFO}\s\S+\s(\S+)\s(\S+)\s(.+)$/) channel = find_model($1) nick = find_model($1) time = Time.at($3.to_i) return Messages::Incoming::TopicInfo.new(string, channel, nick, time) else Logger.log('Failed to parse TOPIC type string') end end |