Class: Ralexa::Paginator::Page
- Inherits:
-
Object
- Object
- Ralexa::Paginator::Page
- Defined in:
- lib/ralexa/paginator.rb
Instance Method Summary collapse
- #count ⇒ Object
- #finish ⇒ Object
- #full? ⇒ Boolean
-
#initialize(page_count, per_page, items, index) ⇒ Page
constructor
A new instance of Page.
- #number ⇒ Object
- #partial? ⇒ Boolean
- #start ⇒ Object
Constructor Details
#initialize(page_count, per_page, items, index) ⇒ Page
Returns a new instance of Page.
23 24 25 26 27 28 |
# File 'lib/ralexa/paginator.rb', line 23 def initialize(page_count, per_page, items, index) @page_count = page_count @per_page = per_page @items = items @index = index end |
Instance Method Details
#count ⇒ Object
42 43 44 |
# File 'lib/ralexa/paginator.rb', line 42 def count if full? then @per_page else @items % @per_page end end |
#finish ⇒ Object
38 39 40 |
# File 'lib/ralexa/paginator.rb', line 38 def finish start + count - 1 end |
#full? ⇒ Boolean
46 47 48 |
# File 'lib/ralexa/paginator.rb', line 46 def full? number < @page_count || @items % @per_page == 0 end |
#number ⇒ Object
30 31 32 |
# File 'lib/ralexa/paginator.rb', line 30 def number @index + 1 end |
#partial? ⇒ Boolean
50 51 52 |
# File 'lib/ralexa/paginator.rb', line 50 def partial? !full? end |
#start ⇒ Object
34 35 36 |
# File 'lib/ralexa/paginator.rb', line 34 def start (@index * @per_page) + 1 end |