Class: Ferret::Search::PhrasePositions
- Inherits:
-
Object
- Object
- Ferret::Search::PhrasePositions
- Defined in:
- lib/ferret/search/phrase_positions.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#next ⇒ Object
Returns the value of attribute next.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Instance Method Summary collapse
- #first_position ⇒ Object
-
#initialize(tp_enum, offset) ⇒ PhrasePositions
constructor
A new instance of PhrasePositions.
- #next? ⇒ Boolean
- #next_position ⇒ Object
- #skip_to(target) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(tp_enum, offset) ⇒ PhrasePositions
Returns a new instance of PhrasePositions.
6 7 8 9 10 11 |
# File 'lib/ferret/search/phrase_positions.rb', line 6 def initialize(tp_enum, offset) @tp_enum = tp_enum @offset = offset @count = @position = @doc = -1 @next = nil end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
3 4 5 |
# File 'lib/ferret/search/phrase_positions.rb', line 3 def doc @doc end |
#next ⇒ Object
Returns the value of attribute next.
4 5 6 |
# File 'lib/ferret/search/phrase_positions.rb', line 4 def next @next end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
3 4 5 |
# File 'lib/ferret/search/phrase_positions.rb', line 3 def position @position end |
Instance Method Details
#first_position ⇒ Object
36 37 38 39 |
# File 'lib/ferret/search/phrase_positions.rb', line 36 def first_position() @count = @tp_enum.freq # read first pos next_position() end |
#next? ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ferret/search/phrase_positions.rb', line 13 def next?() if not @tp_enum.next? @tp_enum.close() # close stream @doc = Scorer::MAX_DOCS # sentinel value return false end @doc = @tp_enum.doc @position = 0 return true end |
#next_position ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/ferret/search/phrase_positions.rb', line 41 def next_position() @count -= 1 if @count >= 0 # read subsequent pos's @position = @tp_enum.next_position() - @offset return true else return false end end |
#skip_to(target) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ferret/search/phrase_positions.rb', line 24 def skip_to(target) if not @tp_enum.skip_to(target) @tp_enum.close() # close stream @doc = Scorer::MAX_DOCS # sentinel value return false end @doc = @tp_enum.doc @position = 0 return true end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/ferret/search/phrase_positions.rb', line 51 def to_s "pp->(doc => #{@doc}, position => #{position})" end |