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, #offset, #page, #size, #to_a

Constructor Details

#initialize(data) ⇒ ArrayPaginator

Returns a new instance of ArrayPaginator.



118
119
120
121
122
123
124
125
# File 'lib/ludy/paginator.rb', line 118

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

Instance Attribute Details

#dataObject (readonly)

data that you passed in this paginator



117
118
119
# File 'lib/ludy/paginator.rb', line 117

def data
  @data
end