Class: Pagify::ArrayPager

Inherits:
BasicPager show all
Includes:
PageAcceptStringOrBlank
Defined in:
lib/pagify/pager/array.rb,
lib/pagify/active_record.rb

Overview

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

Instance Attribute Summary collapse

Attributes inherited from BasicPager

#counter, #fetcher, #opts

Instance Method Summary collapse

Methods inherited from BasicPager

#==, #each, #entries_count, #offset, #page, #page_exists?, #size, #to_a

Constructor Details

#initialize(data, opts = {}) ⇒ ArrayPager

data that you passed in this paginator



10
11
12
13
14
15
16
17
18
19
# File 'lib/pagify/pager/array.rb', line 10

def initialize data, opts = {}
  @data = data
  super(opts.merge(
    :fetcher => lambda{ |offset, per_page|
      data[offset, per_page]
    },
    :counter => lambda{
      data.size
    }))
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/pagify/pager/array.rb', line 7

def data
  @data
end