Class: BitbucketServer::Collection
- Inherits:
-
Enumerator
- Object
- Enumerator
- BitbucketServer::Collection
- Defined in:
- lib/bitbucket_server/collection.rb
Instance Attribute Summary collapse
-
#paginator ⇒ Object
readonly
Returns the value of attribute paginator.
Instance Method Summary collapse
- #current_page ⇒ Object
-
#initialize(paginator) ⇒ Collection
constructor
A new instance of Collection.
- #next_page ⇒ Object
- #prev_page ⇒ Object
Constructor Details
#initialize(paginator) ⇒ Collection
Returns a new instance of Collection.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bitbucket_server/collection.rb', line 9 def initialize(paginator) @paginator = paginator super() do |yielder| loop do paginator.items.each { |item| yielder << item } end end lazy end |
Instance Attribute Details
#paginator ⇒ Object (readonly)
Returns the value of attribute paginator.
5 6 7 |
# File 'lib/bitbucket_server/collection.rb', line 5 def paginator @paginator end |
Instance Method Details
#current_page ⇒ Object
21 22 23 24 25 |
# File 'lib/bitbucket_server/collection.rb', line 21 def current_page return 1 if page_offset <= 1 [1, page_offset].max end |
#next_page ⇒ Object
33 34 35 36 37 |
# File 'lib/bitbucket_server/collection.rb', line 33 def next_page return unless has_next_page? current_page + 1 end |
#prev_page ⇒ Object
27 28 29 30 31 |
# File 'lib/bitbucket_server/collection.rb', line 27 def prev_page return unless current_page > 1 current_page - 1 end |