Class: Toast::Channel
- Inherits:
-
Object
show all
- Defined in:
- lib/channel.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(responder_class) ⇒ Channel
Returns a new instance of Channel.
6
7
8
9
|
# File 'lib/channel.rb', line 6
def initialize responder_class
@responder_class=responder_class
@responders={}
end
|
Instance Attribute Details
#responder_class ⇒ Object
Returns the value of attribute responder_class.
3
4
5
|
# File 'lib/channel.rb', line 3
def responder_class
@responder_class
end
|
#responders ⇒ Object
Returns the value of attribute responders.
4
5
6
|
# File 'lib/channel.rb', line 4
def responders
@responders
end
|
Instance Method Details
#handle(msg) ⇒ Object
11
12
13
|
# File 'lib/channel.rb', line 11
def handle msg
responder_for(msg.from).handle msg.text
end
|
#next_msg ⇒ Object
15
16
17
18
|
# File 'lib/channel.rb', line 15
def next_msg
Message.new("Override #{self.class.name}.next_msg",
'nobody')
end
|
#responder_for(from) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/channel.rb', line 20
def responder_for from
unless @responders[from]
@responders[from]= @responder_class.new self, from
end
@responders[from]
end
|
#send(msg, to) ⇒ Object
27
28
29
|
# File 'lib/channel.rb', line 27
def send msg, to
puts "#{to}: #{msg.text}"
end
|