Class: BitbucketServer::Paginator
- Inherits:
-
Object
- Object
- BitbucketServer::Paginator
- Defined in:
- lib/bitbucket_server/paginator.rb
Constant Summary collapse
- PAGE_LENGTH =
Should be kept in-sync with
BITBUCKET_SERVER_PAGE_LENGTHin app/assets/javascripts/import_entities/constants.js 25
Instance Attribute Summary collapse
-
#page_offset ⇒ Object
readonly
Returns the value of attribute page_offset.
Instance Method Summary collapse
- #has_next_page? ⇒ Boolean
-
#initialize(connection, url, type, page_offset: 0, limit: nil) ⇒ Paginator
constructor
A new instance of Paginator.
- #items ⇒ Object
Constructor Details
#initialize(connection, url, type, page_offset: 0, limit: nil) ⇒ Paginator
Returns a new instance of Paginator.
10 11 12 13 14 15 16 17 18 |
# File 'lib/bitbucket_server/paginator.rb', line 10 def initialize(connection, url, type, page_offset: 0, limit: nil) @connection = connection @type = type @url = url @page = nil @page_offset = page_offset @limit = limit @total = 0 end |
Instance Attribute Details
#page_offset ⇒ Object (readonly)
Returns the value of attribute page_offset.
8 9 10 |
# File 'lib/bitbucket_server/paginator.rb', line 8 def page_offset @page_offset end |
Instance Method Details
#has_next_page? ⇒ Boolean
29 30 31 |
# File 'lib/bitbucket_server/paginator.rb', line 29 def has_next_page? page.nil? || page.next? end |
#items ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/bitbucket_server/paginator.rb', line 20 def items raise StopIteration unless has_next_page? raise StopIteration if over_limit? @page = fetch_next_page @total += @page.items.count @page.items end |