Class: Ludy::ArrayPaginator

Inherits:
Paginator show all
Defined in:
lib/ludy/paginator.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 Paginator

#counter, #fetcher, #per_page

Instance Method Summary collapse

Methods inherited from Paginator

#==, #count, #each, null, #offset, #page, #size, #to_a

Constructor Details

#initialize(data, per_page = 20) ⇒ ArrayPaginator

Returns a new instance of ArrayPaginator.



124
125
126
127
128
129
130
131
# File 'lib/ludy/paginator.rb', line 124

def initialize data, per_page = 20
  @data = data
  super(lambda{ |offset, per_page|
    @data[offset, per_page]
  }, lambda{
    @data.size
  }, per_page)
end

Instance Attribute Details

#dataObject (readonly)

data that you passed in this paginator



123
124
125
# File 'lib/ludy/paginator.rb', line 123

def data
  @data
end