class Polecat::Query
The Query
manages a number of terms or queries which are set into a relation. A relation is needed to say, which documents shall be returned. In a @and@ relation only the documents, which are returned of the query parts get returned. For @or@ all documents found in a part get returned.
Attributes
relation[RW]
returns the relation of the terms @return [Symbol] :and, :or
terms[R]
returns the list of all terms
Public Class Methods
new(relation = :and)
click to toggle source
creates a new query object
Create a new query object. As a default, the relation is set to @:and@ (@see Query#relation
)
# File lib/polecat/query.rb, line 19 def initialize relation = :and if relation == :and || relation == :or @relation = relation else raise ArgumentError, 'no valid relation' end @terms = [] end
Public Instance Methods
add(term)
click to toggle source
add a new term or query
# File lib/polecat/query.rb, line 30 def add term @terms << term self end