Sha256: 5e897baad831b50ff812bbbf1a808d0d7638ddc99f9b09035bec66fe431efab9

Contents?: true

Size: 661 Bytes

Versions: 12

Compression:

Stored size: 661 Bytes

Contents

module Inquisitio
  class Results < Array
    def initialize(items, current_page, results_per_page, total_count, time_ms)
      super(items)
      @current_page, @results_per_page, @total_count, @time_ms = current_page, results_per_page, total_count, time_ms
    end

    attr_reader :total_count, :results_per_page, :current_page, :time_ms
    alias_method :total_entries, :total_count
    alias_method :limit_value, :results_per_page

    def total_pages
      (total_count / results_per_page.to_f).ceil
    end
    alias_method :num_pages, :total_pages

    def last_page?
      current_page == total_pages
    end

    def to_a
      self
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
inquisitio-2.1.2 lib/inquisitio/results.rb
inquisitio-2.1.1 lib/inquisitio/results.rb
inquisitio-2.1.0 lib/inquisitio/results.rb
inquisitio-2.0.0 lib/inquisitio/results.rb
inquisitio-1.5.0 lib/inquisitio/results.rb
inquisitio-1.4.1 lib/inquisitio/results.rb
inquisitio-1.4.0 lib/inquisitio/results.rb
inquisitio-1.3.1 lib/inquisitio/results.rb
inquisitio-1.3.0 lib/inquisitio/results.rb
inquisitio-1.2.4 lib/inquisitio/results.rb
inquisitio-1.2.3 lib/inquisitio/results.rb
inquisitio-1.2.2 lib/inquisitio/results.rb