Class: Hubkit::Paginator Abstract
- Inherits:
-
Object
- Object
- Hubkit::Paginator
- Includes:
- Enumerable
- Defined in:
- lib/hubkit/paginator.rb
Overview
This class is abstract.
A class which implements an Enumerable which yields each resource returned
by GitHub in turn, and handles the pagination for you (acts like a flat array, not an array of pages)
Direct Known Subclasses
Instance Method Summary collapse
-
#each {|result| ... } ⇒ Object
Iterate through each page of the results and perform a block.
-
#initialize {|result| ... } ⇒ Paginator
constructor
Construct a new paginator.
Constructor Details
#initialize {|result| ... } ⇒ Paginator
Construct a new paginator
10 11 12 |
# File 'lib/hubkit/paginator.rb', line 10 def initialize(&block) @block = block end |
Instance Method Details
#each {|result| ... } ⇒ Object
Iterate through each page of the results and perform a block
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hubkit/paginator.rb', line 16 def each i = 1 loop do results = @block.call i results.each do |result| yield result end i += 1 break if results.length == 0 end end |