class ImHungry::Paginate

Attributes

array[RW]
per_page[RW]

Public Class Methods

new(array, per_page) click to toggle source
# File lib/im_hungry/paginate.rb, line 5
def initialize(array, per_page)
  self.array = array
  self.per_page = per_page
end

Public Instance Methods

page_lines(page, i) click to toggle source
# File lib/im_hungry/paginate.rb, line 14
def page_lines(page, i)
  [
    '',
    "Page #{i + 1} of #{pages.length}",
    page.map(&:to_s)
  ]
end
pages() click to toggle source
# File lib/im_hungry/paginate.rb, line 10
def pages
  @pages ||= array.each_slice(per_page).to_a
end
print() click to toggle source
print_page(page, i) click to toggle source