Class: Xing::Services::PagedWrapper
- Inherits:
-
Object
- Object
- Xing::Services::PagedWrapper
- Includes:
- Enumerable
- Defined in:
- lib/xing/services/paged_wrapper.rb
Overview
If you want to use the PagedList serializers, but are using resources that aren’t actually provided by Kaminari, you can instead feed them to PagedWrapper and you should get everything you need
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#page_num ⇒ Object
(also: #current_page)
readonly
Returns the value of attribute page_num.
-
#per_page ⇒ Object
(also: #limit_value)
readonly
Returns the value of attribute per_page.
-
#total_items ⇒ Object
(also: #total_count)
readonly
Returns the value of attribute total_items.
Instance Method Summary collapse
- #each(*args, &block) ⇒ Object
-
#initialize(list, page_num, total_items, per_page) ⇒ PagedWrapper
constructor
A new instance of PagedWrapper.
- #total_pages ⇒ Object
Constructor Details
#initialize(list, page_num, total_items, per_page) ⇒ PagedWrapper
Returns a new instance of PagedWrapper.
8 9 10 |
# File 'lib/xing/services/paged_wrapper.rb', line 8 def initialize(list, page_num, total_items, per_page) @list, @total_items, @per_page, @page_num = list, total_items, per_page, page_num end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
11 12 13 |
# File 'lib/xing/services/paged_wrapper.rb', line 11 def list @list end |
#page_num ⇒ Object (readonly) Also known as: current_page
Returns the value of attribute page_num.
11 12 13 |
# File 'lib/xing/services/paged_wrapper.rb', line 11 def page_num @page_num end |
#per_page ⇒ Object (readonly) Also known as: limit_value
Returns the value of attribute per_page.
11 12 13 |
# File 'lib/xing/services/paged_wrapper.rb', line 11 def per_page @per_page end |
#total_items ⇒ Object (readonly) Also known as: total_count
Returns the value of attribute total_items.
11 12 13 |
# File 'lib/xing/services/paged_wrapper.rb', line 11 def total_items @total_items end |
Instance Method Details
#each(*args, &block) ⇒ Object
21 22 23 |
# File 'lib/xing/services/paged_wrapper.rb', line 21 def each(*args, &block) @list.each(*args, &block) end |
#total_pages ⇒ Object
17 18 19 |
# File 'lib/xing/services/paged_wrapper.rb', line 17 def total_pages (total_items / per_page.to_f).ceil end |