Sha256: 4b4504920684c413b11c4b37cb3e28cc6837b711b69b33dd5ce5d78ce0312ca5

Contents?: true

Size: 601 Bytes

Versions: 2

Compression:

Stored size: 601 Bytes

Contents

module Twitter
  module Enumerable
    include ::Enumerable

    # @return [Enumerator]
    def each(start = 0, &block)
      return to_enum(:each, start) unless block_given?

      Array(@collection[start..]).each(&block)
      unless finished?
        start = [@collection.size, start].max
        fetch_next_page
        each(start, &block)
      end
      self
    end

  private

    # @return [Boolean]
    def last?
      true
    end

    # @return [Boolean]
    def reached_limit?
      false
    end

    # @return [Boolean]
    def finished?
      last? || reached_limit?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter-8.0.0 lib/twitter/enumerable.rb
twitter-8.0.0.rc.1 lib/twitter/enumerable.rb