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.
-
#context ⇒ Object
readonly
Returns the value of attribute 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.
Class Method Summary collapse
Instance Method Summary collapse
- #can_handle? ⇒ Boolean
- #can_respond_to_type?(type) ⇒ Boolean
- #handle ⇒ Object
-
#initialize(message, user, responses, handler, context, analytics) ⇒ Responder
constructor
A new instance of Responder.
Constructor Details
#initialize(message, user, responses, handler, context, analytics) ⇒ Responder
Returns a new instance of Responder.
16 17 18 19 20 21 22 23 |
# File 'lib/bot/responder.rb', line 16 def initialize(, user, responses, handler, context, analytics) @message = @user = user @responses = responses @handler = handler @context = context @analytics = analytics 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 |
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/bot/responder.rb', line 8 def context @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 |
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
30 31 32 |
# File 'lib/bot/responder.rb', line 30 def can_handle? !responses.count end |
#can_respond_to_type?(type) ⇒ Boolean
25 26 27 28 |
# File 'lib/bot/responder.rb', line 25 def can_respond_to_type?(type) = self.class.respond_to_types || ['text'] .include?(type) end |
#handle ⇒ Object
34 35 36 |
# File 'lib/bot/responder.rb', line 34 def handle raise NotImplementedError end |