Class: Plagiarism::Response
- Inherits:
-
Object
- Object
- Plagiarism::Response
- Defined in:
- lib/plagiarism/response.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#body ⇒ Object
Return the body of the response.
-
#error? ⇒ Boolean
Return true if the API call did not succeed.
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
-
#status_code ⇒ Object
Return the HTTP status code from the response.
-
#success? ⇒ Boolean
Return true if the API call succeeded.
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
9 10 11 12 |
# File 'lib/plagiarism/response.rb', line 9 def initialize(response) @response = response @doc = Nokogiri::XML(response.body) if @response.ok? end |
Instance Attribute Details
#doc ⇒ Object
Returns the value of attribute doc.
6 7 8 |
# File 'lib/plagiarism/response.rb', line 6 def doc @doc end |
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/plagiarism/response.rb', line 6 def response @response end |
Instance Method Details
#body ⇒ Object
Return the body of the response
28 29 30 |
# File 'lib/plagiarism/response.rb', line 28 def body @response ? @response.response.body : nil end |
#error? ⇒ Boolean
Return true if the API call did not succeed
22 23 24 |
# File 'lib/plagiarism/response.rb', line 22 def error? not success? end |
#status_code ⇒ Object
Return the HTTP status code from the response
34 35 36 |
# File 'lib/plagiarism/response.rb', line 34 def status_code @response ? @response.response.code : nil end |
#success? ⇒ Boolean
Return true if the API call succeeded
16 17 18 |
# File 'lib/plagiarism/response.rb', line 16 def success? @response.ok? && @doc.css("error").text == "" end |