Class: Kiosk::Indexer::Adapter::ThinkingSphinxAdapter::SearchResults

Inherits:
Array
  • Object
show all
Defined in:
lib/kiosk/indexer/adapter/thinking_sphinx_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sphinx_results, model, search_options) ⇒ SearchResults

Returns a new instance of SearchResults.



128
129
130
131
132
133
134
# File 'lib/kiosk/indexer/adapter/thinking_sphinx_adapter.rb', line 128

def initialize(sphinx_results, model, search_options)
  @model = model
  @results = sphinx_results
  @options = search_options

  populate if @results && @results[:matches]
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



126
127
128
# File 'lib/kiosk/indexer/adapter/thinking_sphinx_adapter.rb', line 126

def results
  @results
end

Instance Method Details

#current_pageObject



136
137
138
# File 'lib/kiosk/indexer/adapter/thinking_sphinx_adapter.rb', line 136

def current_page
  @options[:page].blank? ? 1 : @options[:page].to_i
end

#per_pageObject



140
141
142
# File 'lib/kiosk/indexer/adapter/thinking_sphinx_adapter.rb', line 140

def per_page
  (@options[:per_page] || 20).to_i
end

#total_entriesObject



144
145
146
# File 'lib/kiosk/indexer/adapter/thinking_sphinx_adapter.rb', line 144

def total_entries
  @results[:total_found] || 0
end

#total_pagesObject



148
149
150
# File 'lib/kiosk/indexer/adapter/thinking_sphinx_adapter.rb', line 148

def total_pages
  ((@results[:total] || 0) / per_page.to_f).ceil
end