class ThinkingSphinx::Search::Query

Attributes

conditions[R]
keywords[R]
star[R]

Public Class Methods

new(keywords = '', conditions = {}, star = false) click to toggle source
# File lib/thinking_sphinx/search/query.rb, line 5
def initialize(keywords = '', conditions = {}, star = false)
  @keywords, @conditions, @star = keywords, conditions, star
end

Public Instance Methods

to_s() click to toggle source
# File lib/thinking_sphinx/search/query.rb, line 9
def to_s
  (star_keyword(keywords || '') + ' ' + conditions.keys.collect { |key|
     next if conditions[key].blank?

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

Private Instance Methods

expand_key(key) click to toggle source
# File lib/thinking_sphinx/search/query.rb, line 19
def expand_key(key)
  return "@#{key}" unless key.is_a?(Array)

  "@(#{key.join(',')})"
end
star_keyword(keyword, key = nil) click to toggle source
# File lib/thinking_sphinx/search/query.rb, line 25
def star_keyword(keyword, key = nil)
  return keyword.to_s unless star
  return keyword.to_s if key.to_s == 'sphinx_internal_class_name'

  ThinkingSphinx::Query.wildcard keyword, star
end