Class: Xing::Serializers::PagedList
- Defined in:
- lib/xing/serializers/paged_list.rb
Instance Attribute Summary collapse
-
#page_num ⇒ Object
readonly
Returns the value of attribute page_num.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Instance Method Summary collapse
-
#initialize(list, page_num, total_pages, options = {}) ⇒ PagedList
constructor
A new instance of PagedList.
- #links ⇒ Object
- #next_link ⇒ Object
- #page_link(options) ⇒ Object
- #previous_link ⇒ Object
Methods inherited from List
#as_json_without_wrap, #item_serializer_class, #item_serializer_options, #self_link, #template_link
Methods inherited from Base
#as_json_with_wrap, #root, #routes
Constructor Details
#initialize(list, page_num, total_pages, options = {}) ⇒ PagedList
Returns a new instance of PagedList.
5 6 7 8 9 10 |
# File 'lib/xing/serializers/paged_list.rb', line 5 def initialize(list, page_num, total_pages, = {}) @page_num = page_num.to_i @total_pages = total_pages super(list, ) end |
Instance Attribute Details
#page_num ⇒ Object (readonly)
Returns the value of attribute page_num.
12 13 14 |
# File 'lib/xing/serializers/paged_list.rb', line 12 def page_num @page_num end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
12 13 14 |
# File 'lib/xing/serializers/paged_list.rb', line 12 def total_pages @total_pages end |
Instance Method Details
#links ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/xing/serializers/paged_list.rb', line 27 def links { :self => self_link, :next => next_link, :previous => previous_link } end |
#next_link ⇒ Object
19 20 21 |
# File 'lib/xing/serializers/paged_list.rb', line 19 def next_link page_link({page: page_num + 1}) unless page_num == total_pages end |
#page_link(options) ⇒ Object
14 15 16 17 |
# File 'lib/xing/serializers/paged_list.rb', line 14 def page_link() raise NotImplementedError, "subclasses of Xing::Serializers::PagesData must override page_link to return the URL of a page based on a :page => Integer() hash" end |
#previous_link ⇒ Object
23 24 25 |
# File 'lib/xing/serializers/paged_list.rb', line 23 def previous_link page_link({page: page_num - 1}) unless page_num == 1 end |