Class: FirstGithubCommit

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

Defined Under Namespace

Classes: TooManyRequests

Constant Summary collapse

DEBUG =
false
MAX_REQUESTS =
30

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, repo) ⇒ FirstGithubCommit

Returns a new instance of FirstGithubCommit.



15
16
17
18
19
20
21
# File 'lib/first_github_commit.rb', line 15

def initialize(user, repo)
  @user, @repo = user, repo
  @requests_made = 0
  @range = (1..130)
  find_upper_limit
  find_page_number
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



10
11
12
# File 'lib/first_github_commit.rb', line 10

def page
  @page
end

#repoObject (readonly)

Returns the value of attribute repo.



10
11
12
# File 'lib/first_github_commit.rb', line 10

def repo
  @repo
end

#requests_madeObject (readonly)

Returns the value of attribute requests_made.



10
11
12
# File 'lib/first_github_commit.rb', line 10

def requests_made
  @requests_made
end

#userObject (readonly)

Returns the value of attribute user.



10
11
12
# File 'lib/first_github_commit.rb', line 10

def user
  @user
end

Class Method Details

.find(user, repo) ⇒ Object



31
32
33
# File 'lib/first_github_commit.rb', line 31

def self.find(user, repo)
  FirstGithubCommit.new(user, repo).yaml
end

Instance Method Details

#github_urlObject



27
28
29
# File 'lib/first_github_commit.rb', line 27

def github_url
  @github_url ||= "http://github.com/#{user}/#{repo}/commits/master?page=#{page}"
end

#yamlObject



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

def yaml
  @yaml ||= YAML.load(last_response.body)["commits"].last
end