Class: Bot::Responder
- Inherits:
-
Object
- Object
- Bot::Responder
- Includes:
- ActionView::Helpers::DateHelper, ActionView::Helpers::TextHelper
- Defined in:
- lib/bot/responder.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#analytics ⇒ Object
readonly
Returns the value of attribute analytics.
-
#chat_context ⇒ Object
readonly
Returns the value of attribute chat_context.
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#user_context ⇒ Object
readonly
Returns the value of attribute user_context.
Class Method Summary collapse
Instance Method Summary collapse
- #can_handle? ⇒ Boolean
- #can_respond_to_type?(type) ⇒ Boolean
- #handle ⇒ Object
-
#initialize(message, user, responses, handler, analytics, user_context, chat_context) ⇒ Responder
constructor
A new instance of Responder.
Constructor Details
#initialize(message, user, responses, handler, analytics, user_context, chat_context) ⇒ Responder
Returns a new instance of Responder.
16 17 18 19 20 21 22 23 24 |
# File 'lib/bot/responder.rb', line 16 def initialize(, user, responses, handler, analytics, user_context, chat_context) @message = @user = user @responses = responses @handler = handler @analytics = analytics @user_context = user_context @chat_context = chat_context end |
Instance Attribute Details
#analytics ⇒ Object (readonly)
Returns the value of attribute analytics.
8 9 10 |
# File 'lib/bot/responder.rb', line 8 def analytics @analytics end |
#chat_context ⇒ Object (readonly)
Returns the value of attribute chat_context.
8 9 10 |
# File 'lib/bot/responder.rb', line 8 def chat_context @chat_context end |
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
8 9 10 |
# File 'lib/bot/responder.rb', line 8 def handler @handler end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/bot/responder.rb', line 8 def @message end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
8 9 10 |
# File 'lib/bot/responder.rb', line 8 def responses @responses end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
8 9 10 |
# File 'lib/bot/responder.rb', line 8 def user @user end |
#user_context ⇒ Object (readonly)
Returns the value of attribute user_context.
8 9 10 |
# File 'lib/bot/responder.rb', line 8 def user_context @user_context end |
Class Method Details
.respond_to(*types) ⇒ Object
10 11 12 13 14 |
# File 'lib/bot/responder.rb', line 10 def self.respond_to(*types) new_types = (respond_to_types || []).dup types.each { |type| new_types << type.to_s }.uniq self.respond_to_types = new_types.freeze end |
Instance Method Details
#can_handle? ⇒ Boolean
31 32 33 |
# File 'lib/bot/responder.rb', line 31 def can_handle? !responses.count end |
#can_respond_to_type?(type) ⇒ Boolean
26 27 28 29 |
# File 'lib/bot/responder.rb', line 26 def can_respond_to_type?(type) = self.class.respond_to_types || ['text'] .include?(type) end |
#handle ⇒ Object
35 36 37 |
# File 'lib/bot/responder.rb', line 35 def handle raise NotImplementedError end |