Class: Smackr::Chat
- Inherits:
-
Object
- Object
- Smackr::Chat
- Defined in:
- lib/smackr/chat.rb
Defined Under Namespace
Classes: MessageReceiver
Instance Attribute Summary collapse
-
#chat ⇒ Object
readonly
Returns the value of attribute chat.
-
#chat_manager ⇒ Object
readonly
Returns the value of attribute chat_manager.
-
#message_callback ⇒ Object
Returns the value of attribute message_callback.
-
#messages ⇒ Object
Returns the value of attribute messages.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Chat
constructor
A new instance of Chat.
- #send_message(msg) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Chat
Returns a new instance of Chat.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/smackr/chat.rb', line 7 def initialize(opts={}) unless opts[:chat_manager] raise ArgumentError, ":chat_manager is required" end unless opts[:target] raise ArgumentError, ':target is required' end @chat_manager = opts[:chat_manager] @message_callback = opts[:message_callback] self. = [] @chat = self.chat_manager.create_chat(opts[:target], MessageReceiver.new(:chat => self)) end |
Instance Attribute Details
#chat ⇒ Object (readonly)
Returns the value of attribute chat.
3 4 5 |
# File 'lib/smackr/chat.rb', line 3 def chat @chat end |
#chat_manager ⇒ Object (readonly)
Returns the value of attribute chat_manager.
3 4 5 |
# File 'lib/smackr/chat.rb', line 3 def chat_manager @chat_manager end |
#message_callback ⇒ Object
Returns the value of attribute message_callback.
4 5 6 |
# File 'lib/smackr/chat.rb', line 4 def @message_callback end |
#messages ⇒ Object
Returns the value of attribute messages.
5 6 7 |
# File 'lib/smackr/chat.rb', line 5 def @messages end |
Instance Method Details
#send_message(msg) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/smackr/chat.rb', line 22 def (msg) if msg.is_a?(String) self.chat.(msg) else #TODO take a proper Message object instead of just the message body raise Exception, "NOT IMPLEMENTED, SUCKA" end end |