Class: GithubStats::GithubClient::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/github_stats/github_client.rb

Overview

Auto-paginate!

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Response

Returns a new instance of Response.



24
25
26
# File 'lib/github_stats/github_client.rb', line 24

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



23
24
25
# File 'lib/github_stats/github_client.rb', line 23

def client
  @client
end

Instance Method Details

#each(&block) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/github_stats/github_client.rb', line 28

def each(&block)
  last_response = client.last_response
  loop do
    last_response.data.items.each(&block)
    last_response = last_response.rels[:next].get
    break if last_response.rels[:next].nil?
  end
end