Class: Cognition::Responder
- Inherits:
-
Object
- Object
- Cognition::Responder
- Includes:
- HTTParty
- Defined in:
- lib/cognition/responder.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(uri) ⇒ Responder
constructor
A new instance of Responder.
- #reply(text) ⇒ Object
Constructor Details
#initialize(uri) ⇒ Responder
Returns a new instance of Responder.
7 8 9 10 |
# File 'lib/cognition/responder.rb', line 7 def initialize(uri) @options = { timeout: 5 } @uri = uri end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/cognition/responder.rb', line 5 def url @url end |
Instance Method Details
#reply(text) ⇒ Object
12 13 14 15 16 |
# File 'lib/cognition/responder.rb', line 12 def reply(text) self.class.post(@uri, @options.merge(body: { content: text })) rescue Timeout::Error "Request to #{@uri} timed out." end |