Sha256: 426820580b1f484328f7a8c35d6d43a58ab2564817a546919db49f63270937cd
Contents?: true
Size: 804 Bytes
Versions: 6
Compression:
Stored size: 804 Bytes
Contents
# encoding: UTF-8 require 'forwardable' module Spontaneous::Search # Wraps XapianFu::ResultSet to provide a list of pages rather than a list of # XapianDocs class Results extend Forwardable include Enumerable def_delegators :@results, :current_page, :per_page, :total_pages, :next_page, :offset, :previous_page, :total_entries def initialize(model, result_set, corrected_query = nil) @model = model @results = result_set @corrected_query = corrected_query end def corrected_query @corrected_query || @results.corrected_query end def each pages.each { |page| yield(page) } end def length pages.length end def pages @page_list ||= @model.get(@results.map { |doc| doc.id }) end end # Results end
Version data entries
6 entries across 6 versions & 1 rubygems