Class: Ponder::AsyncIRC::Topic
- Inherits:
-
Object
- Object
- Ponder::AsyncIRC::Topic
- Includes:
- EventMachine::Deferrable
- Defined in:
- lib/ponder/async_irc.rb
Constant Summary collapse
- TIMEOUT =
number of seconds the deferrable will wait for a response before failing
15
Instance Method Summary collapse
-
#initialize(channel, timeout_after, thaum) ⇒ Topic
constructor
A new instance of Topic.
- #succeed(*args) ⇒ Object
- #try(message) ⇒ Object
Constructor Details
#initialize(channel, timeout_after, thaum) ⇒ Topic
Returns a new instance of Topic.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ponder/async_irc.rb', line 13 def initialize(channel, timeout_after, thaum) @channel = channel @thaum = thaum self.timeout(timeout_after) self.errback { @thaum.deferrables.delete self } @thaum.deferrables.add self @thaum.raw "TOPIC #{@channel}" end |
Instance Method Details
#succeed(*args) ⇒ Object
39 40 41 42 |
# File 'lib/ponder/async_irc.rb', line 39 def succeed(*args) @thaum.deferrables.delete self set_deferred_status :succeeded, *args end |
#try(message) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ponder/async_irc.rb', line 24 def try() if =~ /:\S+ (331|332|403|442) \S+ #{Regexp.escape(@channel)} :/i case $1 when '331' succeed({:raw_numeric => 331, :message => 'No topic is set'}) when '332' succeed({:raw_numeric => 332, :message => .scan(/ :(.*)/)[0][0]}) when '403' succeed({:raw_numeric => 403, :message => 'No such channel'}) when '442' succeed({:raw_numeric => 442, :message => "You're not on that channel"}) end end end |