Class: Ferret::Search::ScoreDoc
- Inherits:
-
Object
- Object
- Ferret::Search::ScoreDoc
- Includes:
- Comparable
- Defined in:
- lib/ferret/search/score_doc.rb
Overview
Expert: Returned by low-level search implementations. See TopDocs
Direct Known Subclasses
Instance Attribute Summary collapse
-
#doc ⇒ Object
Expert: A hit document’s number.
-
#score ⇒ Object
Expert: The score of this document for the query.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
score_docA < score_docB if score_docA.score < score_docB.score or score_docA.doc > score_docB.doc.
-
#hash ⇒ Object
returns a hash value for storage in a Hash.
-
#initialize(doc, score) ⇒ ScoreDoc
constructor
Expert: Constructs a ScoreDoc.
- #to_s ⇒ Object
Constructor Details
#initialize(doc, score) ⇒ ScoreDoc
Expert: Constructs a ScoreDoc.
13 14 15 16 |
# File 'lib/ferret/search/score_doc.rb', line 13 def initialize(doc, score) @doc = doc @score = score end |
Instance Attribute Details
#doc ⇒ Object
Expert: A hit document’s number.
10 11 12 |
# File 'lib/ferret/search/score_doc.rb', line 10 def doc @doc end |
#score ⇒ Object
Expert: The score of this document for the query.
7 8 9 |
# File 'lib/ferret/search/score_doc.rb', line 7 def score @score end |
Instance Method Details
#<=>(other) ⇒ Object
score_docA < score_docB if score_docA.score < score_docB.score or score_docA.doc > score_docB.doc
25 26 27 28 29 30 31 32 |
# File 'lib/ferret/search/score_doc.rb', line 25 def <=>(other) result = @score.<=>(other.score) if (result == 0) return other.doc.<=>(@doc) else return result end end |
#hash ⇒ Object
returns a hash value for storage in a Hash
19 20 21 |
# File 'lib/ferret/search/score_doc.rb', line 19 def hash() return 100 * doc * score end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/ferret/search/score_doc.rb', line 34 def to_s "#{@doc} -> %0.2f" % @score end |