Class: Thebes::Sphinxql::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/thebes/sphinxql/query.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ Query

Returns a new instance of Query.



5
6
7
8
# File 'lib/thebes/sphinxql/query.rb', line 5

def initialize query
  @query = query
  @client = Client.new
end

Class Method Details

.run(query) ⇒ Object



27
28
29
# File 'lib/thebes/sphinxql/query.rb', line 27

def run query
  self.new(query).run
end

Instance Method Details

#runObject



10
11
12
# File 'lib/thebes/sphinxql/query.rb', line 10

def run
  @client.query self.to_sql
end

#to_sqlObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/thebes/sphinxql/query.rb', line 14

def to_sql
  case @query
  when String
    @query
  when Array
    @query.shift % (@query.collect { |q|
      @client.escape(q)
    })
  end
end