Sha256: b8a2a851c1bf35175ce44150c0ec41a86cd4073f90f390d63bb4573a0f8775ab

Contents?: true

Size: 644 Bytes

Versions: 14

Compression:

Stored size: 644 Bytes

Contents

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

    attr_reader :total_count, :results_per_page, :current_page
    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

14 entries across 14 versions & 1 rubygems

Version Path
inquisitio-1.2.1 lib/inquisitio/results.rb
inquisitio-1.2.0 lib/inquisitio/results.rb
inquisitio-1.1.2 lib/inquisitio/results.rb
inquisitio-1.1.1 lib/inquisitio/results.rb
inquisitio-1.1.0 lib/inquisitio/results.rb
inquisitio-1.0.0 lib/inquisitio/results.rb
inquisitio-0.2.0 lib/inquisitio/results.rb
inquisitio-0.1.7 lib/inquisitio/results.rb
inquisitio-0.1.6 lib/inquisitio/results.rb
inquisitio-0.1.5 lib/inquisitio/results.rb
inquisitio-0.1.4 lib/inquisitio/results.rb
inquisitio-0.1.3 lib/inquisitio/results.rb
inquisitio-0.1.2 lib/inquisitio/results.rb
inquisitio-0.1.1 lib/inquisitio/results.rb