Class: Ferret::Search::Spans::NearSpansEnum::SpansCell
- Defined in:
- lib/ferret/search/spans/near_spans_enum.rb
Overview
Wraps a SpansEnum, and can be used to form a linked list.
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#next ⇒ Object
Returns the value of attribute next.
Instance Method Summary collapse
- #doc ⇒ Object
- #finish ⇒ Object
-
#initialize(parent, spans, index) ⇒ SpansCell
constructor
A new instance of SpansCell.
- #next? ⇒ Boolean
- #skip_to(target) ⇒ Object
- #start ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(parent, spans, index) ⇒ SpansCell
Returns a new instance of SpansCell.
27 28 29 30 31 32 |
# File 'lib/ferret/search/spans/near_spans_enum.rb', line 27 def initialize(parent, spans, index) @parent = parent @spans = spans @index = index @length = -1 end |
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
25 26 27 |
# File 'lib/ferret/search/spans/near_spans_enum.rb', line 25 def index @index end |
#next ⇒ Object
Returns the value of attribute next.
25 26 27 |
# File 'lib/ferret/search/spans/near_spans_enum.rb', line 25 def next @next end |
Instance Method Details
#doc ⇒ Object
74 |
# File 'lib/ferret/search/spans/near_spans_enum.rb', line 74 def doc() return @spans.doc() end |
#finish ⇒ Object
76 |
# File 'lib/ferret/search/spans/near_spans_enum.rb', line 76 def finish() return @spans.finish() end |
#next? ⇒ Boolean
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ferret/search/spans/near_spans_enum.rb', line 34 def next?() if (@length != -1) # subtract old length @parent.total_length -= @length end more = @spans.next? # move to next if more @length = finish() - start() # compute new length @parent.total_length += @length # add new length to total if (@parent.max.nil? or doc() > @parent.max.doc or # maintain max (doc() == @parent.max.doc and finish() > @parent.max.finish)) @parent.max = self end end return more end |
#skip_to(target) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ferret/search/spans/near_spans_enum.rb', line 54 def skip_to(target) if (@length != -1) # subtract old length @parent.total_length -= @length end more = @spans.skip_to(target) # skip if (more) @length = finish() - start() # compute new length @parent.total_length += @length # add new length to total if (@parent.max == nil or doc() > @parent.max.doc() or # maintain max (doc() == @parent.max.doc and finish() > @parent.max.finish)) @parent.max = self end end return more end |
#start ⇒ Object
75 |
# File 'lib/ferret/search/spans/near_spans_enum.rb', line 75 def start() return @spans.start() end |
#to_s ⇒ Object
78 |
# File 'lib/ferret/search/spans/near_spans_enum.rb', line 78 def to_s() return "#{@spans}##{@index}" end |