module Folio::Ordinal::Page

Public Class Methods

create() click to toggle source
# File lib/folio/ordinal/page.rb, line 79
def self.create
  Folio::Ordinal::BasicPage.new
end

Public Instance Methods

current_page=(value) click to toggle source
# File lib/folio/ordinal/page.rb, line 41
def current_page=(value)
  @current_page = value.to_i
end
first_page() click to toggle source
# File lib/folio/ordinal/page.rb, line 33
def first_page
  1
end
last_page() click to toggle source
# File lib/folio/ordinal/page.rb, line 37
def last_page
  (total_pages || next_page) ? total_pages : current_page
end
next_page() click to toggle source
# File lib/folio/ordinal/page.rb, line 49
def next_page
  if total_pages && current_page >= total_pages
    # known number of pages and we've reached the last one. no next page
    # (even if explicitly set)
    nil
  elsif total_pages || !defined?(@next_page)
    # (1) known number of pages and we haven't reached the last one
    #     (because we're not in the branch above), or
    # (2) unknown number of pages, but nothing set, so we assume an
    #     infinite stream
    # so there's a next page, and it's the one after this one
    current_page + 1
  else
    # just use what they set
    @next_page
  end
end
next_page=(value) click to toggle source
# File lib/folio/ordinal/page.rb, line 45
def next_page=(value)
  @next_page = value && value.to_i
end
offset() click to toggle source
# File lib/folio/ordinal/page.rb, line 75
def offset
  (current_page - 1) * per_page
end
ordinal_pages() click to toggle source
# File lib/folio/ordinal/page.rb, line 28
def ordinal_pages
  true
end
Also aliased as: ordinal_pages?
ordinal_pages?()
Alias for: ordinal_pages
out_of_bounds?() click to toggle source
# File lib/folio/ordinal/page.rb, line 71
def out_of_bounds?
  (current_page < first_page) || (last_page && current_page > last_page) || false
end
previous_page() click to toggle source
# File lib/folio/ordinal/page.rb, line 67
def previous_page
  current_page > first_page ? current_page - 1 : nil
end