Class: Plagiarism::Search
- Inherits:
-
Object
- Object
- Plagiarism::Search
- Defined in:
- lib/plagiarism/search.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#count ⇒ Object
Return the number of results found.
-
#error? ⇒ Boolean
Return true if an error occurred.
-
#results? ⇒ Boolean
Return true if any results were found.
-
#results_url ⇒ Object
Return the URL for viewing results.
-
#success? ⇒ Boolean
Return true if the search request was successful.
-
#words ⇒ Object
Return the number of words checked.
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
4 5 6 |
# File 'lib/plagiarism/search.rb', line 4 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/plagiarism/search.rb', line 4 def response @response end |
Instance Method Details
#count ⇒ Object
Return the number of results found
9 10 11 |
# File 'lib/plagiarism/search.rb', line 9 def count @response.success? ? @response.doc.css("count").text.to_i : nil end |
#error? ⇒ Boolean
Return true if an error occurred
21 22 23 |
# File 'lib/plagiarism/search.rb', line 21 def error? @response && @response.error? ? true : false end |
#results? ⇒ Boolean
Return true if any results were found
15 16 17 |
# File 'lib/plagiarism/search.rb', line 15 def results? count && count > 0 ? true : false end |
#results_url ⇒ Object
Return the URL for viewing results
41 42 43 44 45 46 47 |
# File 'lib/plagiarism/search.rb', line 41 def results_url if @response.success? && viewing_url = @response.doc.css("allviewurl").text viewing_url != "" ? viewing_url : nil else nil end end |
#success? ⇒ Boolean
Return true if the search request was successful
27 28 29 |
# File 'lib/plagiarism/search.rb', line 27 def success? @response && @response.success? ? true : false end |
#words ⇒ Object
Return the number of words checked
34 35 36 |
# File 'lib/plagiarism/search.rb', line 34 def words @response.success? ? @response.doc.css("querywords").text.to_i : nil end |