Module: Twitter::Enumerable

Includes:
Enumerable
Included in:
Cursor, GeoResults, PremiumSearchResults, SearchResults, TrendResults
Defined in:
lib/twitter/enumerable.rb

Instance Method Summary collapse

Instance Method Details

#each(start = 0, &block) ⇒ Enumerator

Returns:

  • (Enumerator)

6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/twitter/enumerable.rb', line 6

def each(start = 0, &block)
  return to_enum(:each, start) unless block_given?

  Array(@collection[start..-1]).each do |element|
    yield(element)
  end
  unless finished?
    start = [@collection.size, start].max
    fetch_next_page
    each(start, &block)
  end
  self
end