Class: ThinkingSphinx::Search::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/search/query.rb

Constant Summary

DEFAULT_TOKEN =
/[\p{Word}\\][\p{Word}\\@]+/

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Query) initialize(keywords = '', conditions = {}, star = false)



8
9
10
# File 'lib/thinking_sphinx/search/query.rb', line 8

def initialize(keywords = '', conditions = {}, star = false)
  @keywords, @conditions, @star = keywords, conditions, star
end

Instance Attribute Details

- (Object) conditions (readonly)

Returns the value of attribute conditions



6
7
8
# File 'lib/thinking_sphinx/search/query.rb', line 6

def conditions
  @conditions
end

- (Object) keywords (readonly)

Returns the value of attribute keywords



6
7
8
# File 'lib/thinking_sphinx/search/query.rb', line 6

def keywords
  @keywords
end

- (Object) star (readonly)

Returns the value of attribute star



6
7
8
# File 'lib/thinking_sphinx/search/query.rb', line 6

def star
  @star
end

Instance Method Details

- (Object) to_s



12
13
14
15
16
17
18
# File 'lib/thinking_sphinx/search/query.rb', line 12

def to_s
  (star_keyword(keywords || '') + ' ' + conditions.keys.collect { |key|
     next if conditions[key].blank?

    "@#{key} #{star_keyword conditions[key], key}"
  }.join(' ')).strip
end