Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0']
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4']

steps:
- uses: actions/checkout@v2
Expand Down
11 changes: 5 additions & 6 deletions lib/dothoop/paginated_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@ def [](index)
@collection[index]
end

def each(start = 0)
def each(start = 0, &block)
# Start off with the first page if we have no idea of anything yet
fetch_next_page if total.nil?

return to_enum(:each, start) unless block_given?
Array(@collection[start..-1]).each do |element|
yield(element)
end
return to_enum(:each, start) unless block

Array(@collection[start..-1]).each(&block)

unless last?
start = [@collection.size, start].max
fetch_next_page
each(start, &Proc.new)
each(start, &block)
end

self
Expand Down
2 changes: 1 addition & 1 deletion lib/dothoop/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Dothoop
VERSION = "0.1.7"
VERSION = "0.1.8"
end