Module: Folio::Page

Includes:
PerPage
Included in:
BasicPage
Defined in:
lib/folio/page.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PerPage

#default_per_page, #per_page

Instance Attribute Details

#current_pageObject

page identifier addressing this page within the folio.



26
27
28
# File 'lib/folio/page.rb', line 26

def current_page
  @current_page
end

#first_pageObject

page identifier addressing the first page within the folio.



32
33
34
# File 'lib/folio/page.rb', line 32

def first_page
  @first_page
end

#next_pageObject

page identifier addressing the immediately following page within the folio, if there is one.



50
51
52
# File 'lib/folio/page.rb', line 50

def next_page
  @next_page
end

#ordinal_pagesObject Also known as: ordinal_pages?

indicates whether the page identifiers in current_page, first_page, last_page, previous_page, and next_page should be considered ordinal or not.



22
23
24
# File 'lib/folio/page.rb', line 22

def ordinal_pages
  @ordinal_pages
end

#previous_pageObject

page identifier addressing the immediately preceding page within the folio, if there is one and it is known.



54
55
56
# File 'lib/folio/page.rb', line 54

def previous_page
  @previous_page
end

#total_entriesObject

number of items in the folio, if known.



57
58
59
# File 'lib/folio/page.rb', line 57

def total_entries
  @total_entries
end

Class Method Details

.createObject



67
68
69
# File 'lib/folio/page.rb', line 67

def self.create
  Folio::BasicPage.new
end

Instance Method Details

#last_pageObject



40
41
42
43
44
45
46
# File 'lib/folio/page.rb', line 40

def last_page
  if next_page.nil?
    current_page
  else
    @last_page
  end
end

#last_page=(value) ⇒ Object

page identifier addressing the final page within the folio, if known.



36
37
38
# File 'lib/folio/page.rb', line 36

def last_page=(value)
  @last_page = value
end

#total_pagesObject

number of pages in the folio, if known. calculated from total_entries and per_page.



61
62
63
64
65
# File 'lib/folio/page.rb', line 61

def total_pages
  return nil unless total_entries && per_page && per_page > 0
  return 1 if total_entries <= 0
  (total_entries / per_page.to_f).ceil
end