Creating an infinite loop in Ruby
If you need to iterate over a collection that its size is unknown, you can create an infinite loops in ruby easily, but if you need an index, then there's this option:
(1..).each do |page|
results = ExternalService.get('/endpoint', page: page)
parsed = JSON.parse(response.body)
break if parsed['data'].empty?
process_data(parsed['data'])
end