Class: Pandorified::Result
- Inherits:
-
Object
- Object
- Pandorified::Result
- Defined in:
- lib/pandorified/result.rb
Overview
The result of sending a message to a bot, including the response message if successful.
Instance Method Summary collapse
-
#botid ⇒ String
The botid of the bot this result is for.
-
#custid ⇒ String
The custid for this session.
-
#error? ⇒ Boolean
‘true` if Pandorabots returned an error.
-
#initialize(params) ⇒ Result
constructor
A new instance of Result.
-
#input ⇒ String
The orginal input that triggered this response.
-
#message ⇒ String
(also: #error, #error_message)
The error message as returned by Pandorabots, if an error occured.
-
#status ⇒ Number
Check the status of this result.
-
#success? ⇒ Boolean
(also: #ok?, #successful?)
‘true` if this result was successful (no error was returned by Pandorabots), `false` otherwise.
-
#that ⇒ String
(also: #to_s)
The bot’s response to the input.
Constructor Details
Instance Method Details
#botid ⇒ String
Returns The botid of the bot this result is for.
59 60 61 |
# File 'lib/pandorified/result.rb', line 59 def botid @botid ||= @xml.xpath('/result/@botid').first.value end |
#custid ⇒ String
Returns The custid for this session.
64 65 66 |
# File 'lib/pandorified/result.rb', line 64 def custid @custid ||= @xml.xpath('/result/@custid').first.value end |
#error? ⇒ Boolean
After checking if there is an error, you can read the error message with #message.
Returns ‘true` if Pandorabots returned an error.
43 44 45 |
# File 'lib/pandorified/result.rb', line 43 def error? !success? end |
#input ⇒ String
Returns The orginal input that triggered this response.
69 70 71 |
# File 'lib/pandorified/result.rb', line 69 def input @input ||= @xml.xpath('/result/input').first.text end |
#message ⇒ String Also known as: error, error_message
Returns The error message as returned by Pandorabots, if an error occured.
49 50 51 52 53 |
# File 'lib/pandorified/result.rb', line 49 def return nil if success? @message ||= @xml.xpath('/result/message').first.text end |
#status ⇒ Number
26 27 28 |
# File 'lib/pandorified/result.rb', line 26 def status @status ||= @xml.xpath('/result/@status').first.value.to_i end |
#success? ⇒ Boolean Also known as: ok?, successful?
Returns ‘true` if this result was successful (no error was returned by Pandorabots), `false` otherwise.
32 33 34 |
# File 'lib/pandorified/result.rb', line 32 def success? status.zero? end |
#that ⇒ String Also known as: to_s
Returns The bot’s response to the input.
17 18 19 |
# File 'lib/pandorified/result.rb', line 17 def that @that ||= @xml.xpath('/result/that').first.text.strip end |