Class: Cognition::Responder

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/cognition/responder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#urlObject (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