Class: Ferret::Index::TermEnum

Inherits:
Object
  • Object
show all
Defined in:
lib/ferret/index/term_enum.rb

Overview

Abstract class for enumerating terms.

Term enumerations are always ordered by Term.<=>. Each term in the enumeration is greater than all that precede it.

Instance Method Summary collapse

Instance Method Details

#closeObject

Closes the enumeration to further activity, freeing resources.

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/ferret/index/term_enum.rb', line 24

def close
  raise NotImplementedError
end

#doc_freqObject

Returns the doc_freq of the current Term in the enumeration.

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/ferret/index/term_enum.rb', line 19

def doc_freq
  raise NotImplementedError
end

#next?Boolean

Increments the enumeration to the next element. True if one exists.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


9
10
11
# File 'lib/ferret/index/term_enum.rb', line 9

def next?
  raise NotImplementedError
end

#skip_to(term) ⇒ Object

Term Vector support Skips terms to the first beyond the current whose value is greater or equal to target.

Returns true iff there is such a term.

Behaves as if written:

def skip_to(target_term)
  while (target > term)
    if (!next()) return false
  end
  return true
end

Some implementations are considerably more efficient than that.



44
45
46
47
48
49
# File 'lib/ferret/index/term_enum.rb', line 44

def skip_to(term)
  while (target > term)
    return false if not next?
  end
  return true
end

#termObject

Returns the current Term in the enumeration.

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/ferret/index/term_enum.rb', line 14

def term
  raise NotImplementedError
end