Sha256: 18582279c93fc51a6662b31aa8955d8018dbaff40f8a15291eb6021f21be705f

Contents?: true

Size: 587 Bytes

Versions: 7

Compression:

Stored size: 587 Bytes

Contents

module Pagify
  # array paginator would just simply assume your data is an array,
  # and create pages simply for your_data[offset, per_page]
  # if your data is much more complex, use Paginator instead of this
  class ArrayPager < BasicPager
    attr_reader :data

    # data that you passed in this paginator
    def initialize data, opts = {}
      @data = data
      super(opts.merge(
        :fetcher => lambda{ |offset, per_page|
          data[offset, per_page]
        },
        :counter => lambda{
          data.size
        }))
    end
  end # of ArrayPager
end # of Pagify

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
godfat-pagify-0.6.1 lib/pagify/pager/array.rb
godfat-pagify-0.6.2 lib/pagify/pager/array.rb
pagify-0.8.0 lib/pagify/pager/array.rb
pagify-0.7.1 lib/pagify/pager/array.rb
pagify-0.7.0 lib/pagify/pager/array.rb
pagify-0.6.2 lib/pagify/pager/array.rb
pagify-0.6.1 lib/pagify/pager/array.rb