Class: Polecat::Term

Inherits:
Object
  • Object
show all
Defined in:
lib/polecat/term.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, operator, value) ⇒ Term

create a new Term for a query



11
12
13
14
15
16
17
18
19
# File 'lib/polecat/term.rb', line 11

def initialize field, operator, value
  @field = field
  @operator = operator
  if @operator == :eq && value.class == String
    @value = /^#{value}$/
  else
    @value = value
  end
end

Instance Attribute Details

#fieldObject (readonly)

the field name which should be found



4
5
6
# File 'lib/polecat/term.rb', line 4

def field
  @field
end

#operatorObject (readonly)

the operator to match the field with the value



6
7
8
# File 'lib/polecat/term.rb', line 6

def operator
  @operator
end

#valueObject (readonly)

the search value which get’s matched against the document field



8
9
10
# File 'lib/polecat/term.rb', line 8

def value
  @value
end