Class: Ahoy::Broadcast
- Inherits:
-
Object
- Object
- Ahoy::Broadcast
- Defined in:
- lib/ahoy/broadcast.rb
Overview
Instance Method Summary collapse
-
#close ⇒ Object
:call-seq: broadcast.close -> close.
-
#initialize(user) ⇒ Broadcast
constructor
:call-seq: Broadcast.new(user) -> broadcast.
-
#send(message) ⇒ Object
:call-seq: broadcast.send(string) -> array.
Constructor Details
#initialize(user) ⇒ Broadcast
:call-seq: Broadcast.new(user) -> broadcast
Create a new Ahoy::Broadcast.
19 20 21 22 23 |
# File 'lib/ahoy/broadcast.rb', line 19 def initialize(user) user.sign_in sleep 1 @chats = user.contacts.map {|cont| user.chat(cont) rescue nil}.compact end |
Instance Method Details
#close ⇒ Object
:call-seq: broadcast.close -> close
End all chats.
43 44 45 |
# File 'lib/ahoy/broadcast.rb', line 43 def close @chats.each {|chat| chat.close} end |
#send(message) ⇒ Object
:call-seq: broadcast.send(string) -> array
Send string to all online contacts.
29 30 31 32 33 34 35 36 37 |
# File 'lib/ahoy/broadcast.rb', line 29 def send() @chats.each do |chat| begin chat.send() rescue @chats.delete(chat) end end end |