Class: Kiosk::Indexer::Adapter::ThinkingSphinxAdapter::SearchResults
- Inherits:
-
Array
- Object
- Array
- Kiosk::Indexer::Adapter::ThinkingSphinxAdapter::SearchResults
- Defined in:
- lib/kiosk/indexer/adapter/thinking_sphinx_adapter.rb
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #current_page ⇒ Object
-
#initialize(sphinx_results, model, search_options) ⇒ SearchResults
constructor
A new instance of SearchResults.
- #per_page ⇒ Object
- #total_entries ⇒ Object
- #total_pages ⇒ Object
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, ) @model = model @results = sphinx_results @options = populate if @results && @results[:matches] end |
Instance Attribute Details
#results ⇒ Object (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_page ⇒ Object
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_page ⇒ Object
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_entries ⇒ Object
144 145 146 |
# File 'lib/kiosk/indexer/adapter/thinking_sphinx_adapter.rb', line 144 def total_entries @results[:total_found] || 0 end |
#total_pages ⇒ Object
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 |