Class: Bitly::API::Bitlink::PaginatedList
- Defined in:
- lib/bitly/api/bitlink/paginated_list.rb
Instance Attribute Summary collapse
-
#next_url ⇒ Object
readonly
Returns the value of attribute next_url.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#prev_url ⇒ Object
readonly
Returns the value of attribute prev_url.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Attributes inherited from List
Instance Method Summary collapse
- #has_next_page? ⇒ Boolean
- #has_prev_page? ⇒ Boolean
-
#initialize(items:, response:, client:) ⇒ PaginatedList
constructor
A new instance of PaginatedList.
- #next_page ⇒ Object
- #prev_page ⇒ Object
Methods inherited from List
Constructor Details
#initialize(items:, response:, client:) ⇒ PaginatedList
Returns a new instance of PaginatedList.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bitly/api/bitlink/paginated_list.rb', line 11 def initialize(items:, response: , client:) super(items: items, response: response) @client = client if response.body["pagination"] pagination = response.body["pagination"] @next_url = pagination["next"] @prev_url = pagination["prev"] @size = pagination["size"] @page = pagination["page"] @total = pagination["total"] end end |
Instance Attribute Details
#next_url ⇒ Object (readonly)
Returns the value of attribute next_url.
9 10 11 |
# File 'lib/bitly/api/bitlink/paginated_list.rb', line 9 def next_url @next_url end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
9 10 11 |
# File 'lib/bitly/api/bitlink/paginated_list.rb', line 9 def page @page end |
#prev_url ⇒ Object (readonly)
Returns the value of attribute prev_url.
9 10 11 |
# File 'lib/bitly/api/bitlink/paginated_list.rb', line 9 def prev_url @prev_url end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
9 10 11 |
# File 'lib/bitly/api/bitlink/paginated_list.rb', line 9 def size @size end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
9 10 11 |
# File 'lib/bitly/api/bitlink/paginated_list.rb', line 9 def total @total end |
Instance Method Details
#has_next_page? ⇒ Boolean
24 25 26 |
# File 'lib/bitly/api/bitlink/paginated_list.rb', line 24 def has_next_page? !next_url.nil? && !next_url.empty? end |
#has_prev_page? ⇒ Boolean
28 29 30 |
# File 'lib/bitly/api/bitlink/paginated_list.rb', line 28 def has_prev_page? !prev_url.nil? && !prev_url.empty? end |
#next_page ⇒ Object
32 33 34 |
# File 'lib/bitly/api/bitlink/paginated_list.rb', line 32 def next_page has_next_page? ? get_page(uri: URI(next_url)) : nil end |
#prev_page ⇒ Object
36 37 38 |
# File 'lib/bitly/api/bitlink/paginated_list.rb', line 36 def prev_page has_prev_page? ? get_page(uri: URI(prev_url)) : nil end |