Class: Sinbotra::MessageHandler
- Inherits:
-
Object
- Object
- Sinbotra::MessageHandler
- Defined in:
- lib/sinbotra/message_handler.rb
Class Attribute Summary collapse
-
.handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Instance Attribute Summary collapse
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Class Method Summary collapse
Instance Method Summary collapse
- #handler_class ⇒ Object
-
#initialize(provider, async = true) ⇒ MessageHandler
constructor
A new instance of MessageHandler.
- #receive_messages(messages) ⇒ Object
Constructor Details
#initialize(provider, async = true) ⇒ MessageHandler
Returns a new instance of MessageHandler.
13 14 15 16 |
# File 'lib/sinbotra/message_handler.rb', line 13 def initialize(provider, async=true) @provider = provider @is_async = async end |
Class Attribute Details
.handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
3 4 5 |
# File 'lib/sinbotra/message_handler.rb', line 3 def handlers @handlers end |
Instance Attribute Details
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
11 12 13 |
# File 'lib/sinbotra/message_handler.rb', line 11 def provider @provider end |
Class Method Details
.add_handler(provider, handler) ⇒ Object
5 6 7 8 |
# File 'lib/sinbotra/message_handler.rb', line 5 def add_handler(provider, handler) @handlers ||= {} @handlers[provider] = handler end |
Instance Method Details
#handler_class ⇒ Object
25 |
# File 'lib/sinbotra/message_handler.rb', line 25 def handler_class; self.class.handlers[@provider]; end |
#receive_messages(messages) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/sinbotra/message_handler.rb', line 18 def () .each do |msg| bot = handler_class.new(msg) bot.respond end end |