Module: Card::Set::Abstract::Paging::Format
- Extended by:
- Card::Set::AbstractFormat
- Defined in:
- platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging.rb
Instance Method Summary collapse
-
#count_with_params ⇒ Object
-
#current_page ⇒ Object
-
#extra_paging_path_args ⇒ Object
for override.
-
#last_item_on_page ⇒ Object
-
#limit ⇒ Object
-
#no_results? ⇒ Boolean
-
#offset ⇒ Object
-
#search_with_params ⇒ Object
-
#total_pages ⇒ Object
Instance Method Details
#count_with_params ⇒ Object
23 24 25 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging.rb', line 23 def count_with_params @count_with_params ||= card.item_names.count end |
#current_page ⇒ Object
37 38 39 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging.rb', line 37 def current_page (offset / limit).to_i end |
#extra_paging_path_args ⇒ Object
for override
42 43 44 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging.rb', line 42 def extra_paging_path_args {} end |
#last_item_on_page ⇒ Object
46 47 48 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging.rb', line 46 def last_item_on_page [count_with_params, (offset + limit)].min end |
#limit ⇒ Object
11 12 13 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging.rb', line 11 def limit @limit ||= contextual_param(:limit) || default_limit end |
#no_results? ⇒ Boolean
27 28 29 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging.rb', line 27 def no_results? count_with_params.zero? end |
#offset ⇒ Object
15 16 17 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging.rb', line 15 def offset @offset ||= contextual_param(:offset) || 0 end |
#search_with_params ⇒ Object
19 20 21 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging.rb', line 19 def search_with_params @search_with_params ||= card.item_names end |
#total_pages ⇒ Object
31 32 33 34 35 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging.rb', line 31 def total_pages return 1 if limit.zero? ((count_with_params - 1) / limit).to_i end |