Class: Zwite::Pagination::Page
Instance Attribute Summary collapse
-
#end_index ⇒ Object
Returns the value of attribute end_index.
-
#has_next ⇒ Object
Returns the value of attribute has_next.
-
#has_other_pages ⇒ Object
Returns the value of attribute has_other_pages.
-
#has_prev ⇒ Object
Returns the value of attribute has_prev.
-
#next_page_number ⇒ Object
Returns the value of attribute next_page_number.
-
#number ⇒ Object
Returns the value of attribute number.
-
#objects ⇒ Object
Returns the value of attribute objects.
-
#paginator ⇒ Object
Properties.
-
#prev_page_number ⇒ Object
Returns the value of attribute prev_page_number.
-
#start_index ⇒ Object
Returns the value of attribute start_index.
Instance Method Summary collapse
-
#initialize(paginator, objects, number) ⇒ Page
constructor
Initialization.
- #to_liquid ⇒ Object
Constructor Details
#initialize(paginator, objects, number) ⇒ Page
Initialization
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/zwite/core/pagination.rb', line 39 def initialize(paginator, objects, number) self.paginator = paginator self.objects = objects self.number = number self.has_next = (self.number < self.paginator.pages_count) self.has_prev = (self.number > 1) self.has_other_pages = (self.has_next || self.has_prev) self.next_page_number = self.number + 1 self.prev_page_number = self.number - 1 self.start_index = (self.paginator.pages_count == 0) ? 0 : (self.paginator.per_page * (self.number - 1)) + 1 self.end_index = (self.paginator.pages_count == self.number) ? self.paginator.pages_count : self.number * self.paginator.per_page end |
Instance Attribute Details
#end_index ⇒ Object
Returns the value of attribute end_index.
20 21 22 |
# File 'lib/zwite/core/pagination.rb', line 20 def end_index @end_index end |
#has_next ⇒ Object
Returns the value of attribute has_next.
14 15 16 |
# File 'lib/zwite/core/pagination.rb', line 14 def has_next @has_next end |
#has_other_pages ⇒ Object
Returns the value of attribute has_other_pages.
16 17 18 |
# File 'lib/zwite/core/pagination.rb', line 16 def has_other_pages @has_other_pages end |
#has_prev ⇒ Object
Returns the value of attribute has_prev.
15 16 17 |
# File 'lib/zwite/core/pagination.rb', line 15 def has_prev @has_prev end |
#next_page_number ⇒ Object
Returns the value of attribute next_page_number.
17 18 19 |
# File 'lib/zwite/core/pagination.rb', line 17 def next_page_number @next_page_number end |
#number ⇒ Object
Returns the value of attribute number.
13 14 15 |
# File 'lib/zwite/core/pagination.rb', line 13 def number @number end |
#objects ⇒ Object
Returns the value of attribute objects.
12 13 14 |
# File 'lib/zwite/core/pagination.rb', line 12 def objects @objects end |
#paginator ⇒ Object
Properties
11 12 13 |
# File 'lib/zwite/core/pagination.rb', line 11 def paginator @paginator end |
#prev_page_number ⇒ Object
Returns the value of attribute prev_page_number.
18 19 20 |
# File 'lib/zwite/core/pagination.rb', line 18 def prev_page_number @prev_page_number end |
#start_index ⇒ Object
Returns the value of attribute start_index.
19 20 21 |
# File 'lib/zwite/core/pagination.rb', line 19 def start_index @start_index end |
Instance Method Details
#to_liquid ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/zwite/core/pagination.rb', line 22 def to_liquid return { "objects" => self.objects, "number" => self.number, "has_next" => self.has_next, "has_prev" => self.has_prev, "has_other_pages" => self.has_other_pages, "next_page_number" => self.next_page_number, "prev_page_number" => self.prev_page_number, "start_index" => self.start_index, "end_index" => self.end_index } end |