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

Instance Method Details

#count_with_paramsObject



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_pageObject



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_argsObject

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_pageObject



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

#limitObject



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

Returns:

  • (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

#offsetObject



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_paramsObject



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_pagesObject



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