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.
-
#percentage_matched ⇒ Object
Return the percentage of words matched from the source.
-
#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.
-
#words_matched ⇒ Object
Return the number of words matched from the source.
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
22 23 24 |
# File 'lib/plagiarism/search.rb', line 22 def error? @response && @response.error? ? true : false end |
#percentage_matched ⇒ Object
Return the percentage of words matched from the source
54 55 56 57 58 59 60 |
# File 'lib/plagiarism/search.rb', line 54 def percentage_matched if @response.success? && percentage = @response.doc.css("allpercentmatched").text percentage != "" ? percentage.to_i : nil else nil end end |
#results? ⇒ Boolean
Return true if any results were found
16 17 18 |
# File 'lib/plagiarism/search.rb', line 16 def results? count && count > 0 ? true : false end |
#results_url ⇒ Object
Return the URL for viewing results
65 66 67 |
# File 'lib/plagiarism/search.rb', line 65 def results_url @response.doc.css("allviewurl").text if results? end |
#success? ⇒ Boolean
Return true if the search request was successful
29 30 31 |
# File 'lib/plagiarism/search.rb', line 29 def success? @response && @response.success? ? true : false end |
#words ⇒ Object
Return the number of words checked
36 37 38 |
# File 'lib/plagiarism/search.rb', line 36 def words @response.success? ? @response.doc.css("querywords").text.to_i : nil end |
#words_matched ⇒ Object
Return the number of words matched from the source
43 44 45 46 47 48 49 |
# File 'lib/plagiarism/search.rb', line 43 def words_matched if @response.success? && words = @response.doc.css("allwordsmatched").text words != "" ? words.to_i : nil else nil end end |