Class: Ferret::Search::FilteredTermEnum
- Inherits:
-
Index::TermEnum
- Object
- Index::TermEnum
- Ferret::Search::FilteredTermEnum
- Defined in:
- lib/ferret/search/filtered_term_enum.rb
Overview
Abstract class for enumerating a subset of all terms.
Term enumerations are always ordered by Term.<=>(). Each term in the enumeration is greater than all that precede it.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#term ⇒ Object
readonly
Returns the current Term in the enumeration.
Instance Method Summary collapse
-
#close ⇒ Object
Closes the enumeration to further activity, freeing resources.
-
#difference ⇒ Object
Equality measure on the term.
-
#doc_freq ⇒ Object
Returns the doc_freq of the current Term in the enumeration.
-
#end_enum ⇒ Object
Indiciates the end of the enumeration has been reached.
- #enum=(enum) ⇒ Object
-
#initialize ⇒ FilteredTermEnum
constructor
A new instance of FilteredTermEnum.
-
#next? ⇒ Boolean
Increments the enumeration to the next element.
-
#term_compare(term) ⇒ Object
Equality compare on the term.
Methods inherited from Index::TermEnum
Constructor Details
#initialize ⇒ FilteredTermEnum
Returns a new instance of FilteredTermEnum.
13 14 15 16 17 |
# File 'lib/ferret/search/filtered_term_enum.rb', line 13 def initialize() @term = nil @enum = nil @reader = nil end |
Instance Attribute Details
#term ⇒ Object (readonly)
Returns the current Term in the enumeration. Returns nil if no Term matches or all terms have been enumerated.
11 12 13 |
# File 'lib/ferret/search/filtered_term_enum.rb', line 11 def term @term end |
Instance Method Details
#close ⇒ Object
Closes the enumeration to further activity, freeing resources.
73 74 75 76 77 |
# File 'lib/ferret/search/filtered_term_enum.rb', line 73 def close() @enum.close() @term = nil @enum = nil end |
#difference ⇒ Object
Equality measure on the term
25 26 27 |
# File 'lib/ferret/search/filtered_term_enum.rb', line 25 def difference() raise NotImplementedError end |
#doc_freq ⇒ Object
Returns the doc_freq of the current Term in the enumeration. Returns -1 if no Term matches or all terms have been enumerated.
47 48 49 50 51 52 |
# File 'lib/ferret/search/filtered_term_enum.rb', line 47 def doc_freq() if (@enum == nil) return -1 end return @enum.doc_freq() end |
#end_enum ⇒ Object
Indiciates the end of the enumeration has been reached
30 31 32 |
# File 'lib/ferret/search/filtered_term_enum.rb', line 30 def end_enum() raise NotImplementedError end |
#enum=(enum) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ferret/search/filtered_term_enum.rb', line 34 def enum=(enum) @enum = enum # Find the first term that matches term = @enum.term() if (term != nil and term_compare(term)) @term = term else next? end end |
#next? ⇒ Boolean
Increments the enumeration to the next element. True if one exists.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ferret/search/filtered_term_enum.rb', line 55 def next?() return false if (@enum == nil) # enum not initialized @term = nil while @term.nil? if end_enum() or ! @enum.next? return false end term = @enum.term() if (term_compare(term)) @term = term return true end end @term = nil return false end |
#term_compare(term) ⇒ Object
Equality compare on the term
20 21 22 |
# File 'lib/ferret/search/filtered_term_enum.rb', line 20 def term_compare(term) raise NotImplementedError end |