Class: Jekyll::Plugins::PaginateV3::Pagination::IndexReference
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Jekyll::Plugins::PaginateV3::Pagination::IndexReference
- Defined in:
- lib/jekyll-paginate-v3/pagination/paginator/index_reference.rb
Overview
Lightweight Liquid-facing object for paginator neighbour links.
Exposed under paginator.current, paginator.next, paginator.previous,
alias paginator.prev, plus paginator.first and paginator.last.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#num ⇒ Object
readonly
Returns the value of attribute num.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
-
#count ⇒ Object
Number of items paginated to this index.
-
#initialize(num:, page_object:, item_count:, start_item_index:, end_item_index:) ⇒ IndexReference
constructor
Stores one page number plus optional page/document object and positional metadata within the full paginated set.
-
#liquid_method_missing(method_name) ⇒ Object
Handles
endbecause it is a Ruby keyword and cannot be a method name. -
#start ⇒ Object
1-based index of the first item on this index.
-
#to_h ⇒ Object
Hash form used by specs and non-Liquid inspection.
Constructor Details
#initialize(num:, page_object:, item_count:, start_item_index:, end_item_index:) ⇒ IndexReference
Stores one page number plus optional page/document object and positional metadata within the full paginated set.
17 18 19 20 21 22 23 |
# File 'lib/jekyll-paginate-v3/pagination/paginator/index_reference.rb', line 17 def initialize(num:, page_object:, item_count:, start_item_index:, end_item_index:) @num = num.to_i @page = page_object @item_count = item_count.to_i @start_item_index = start_item_index @end_item_index = end_item_index end |
Instance Attribute Details
#num ⇒ Object (readonly)
Returns the value of attribute num.
13 14 15 |
# File 'lib/jekyll-paginate-v3/pagination/paginator/index_reference.rb', line 13 def num @num end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
13 14 15 |
# File 'lib/jekyll-paginate-v3/pagination/paginator/index_reference.rb', line 13 def page @page end |
Instance Method Details
#count ⇒ Object
Number of items paginated to this index.
26 27 28 |
# File 'lib/jekyll-paginate-v3/pagination/paginator/index_reference.rb', line 26 def count @item_count end |
#liquid_method_missing(method_name) ⇒ Object
Handles end because it is a Ruby keyword and cannot be a method name.
47 48 49 50 51 |
# File 'lib/jekyll-paginate-v3/pagination/paginator/index_reference.rb', line 47 def liquid_method_missing(method_name) return @end_item_index if method_name.to_s == 'end' super end |
#start ⇒ Object
1-based index of the first item on this index.
31 32 33 |
# File 'lib/jekyll-paginate-v3/pagination/paginator/index_reference.rb', line 31 def start @start_item_index end |
#to_h ⇒ Object
Hash form used by specs and non-Liquid inspection.
36 37 38 39 40 41 42 43 44 |
# File 'lib/jekyll-paginate-v3/pagination/paginator/index_reference.rb', line 36 def to_h { 'num' => num, 'page' => page, 'count' => count, 'start' => start, 'end' => @end_item_index } end |