Skip to content

Commit

Permalink
Creates a head method to be more consistent.
Browse files Browse the repository at this point in the history
  • Loading branch information
icco committed May 25, 2012
1 parent 1e0395d commit 92bc4c3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/octokit/request.rb
Expand Up @@ -22,18 +22,22 @@ def put(path, options={}, version=api_version, authenticate=true, raw=false, for
request(:put, path, options, version, authenticate, raw, force_urlencoded) request(:put, path, options, version, authenticate, raw, force_urlencoded)
end end


def head(path, options={}, version=api_version, authenticate=true, raw=true, force_urlencoded=false)
request(:head, path, options, version, authenticate, raw, force_urlencoded)
end

def ratelimit(force=false) def ratelimit(force=false)
headers = @last_header headers = @last_header
if @last_header == nil || force if @last_header == nil || force
headers = request(:head, "/", {}, api_version, true, true, false) headers = head("/")
end end
return headers["X-RateLimit-Limit"].to_i return headers["X-RateLimit-Limit"].to_i
end end


def ratelimit_remaining(force=false) def ratelimit_remaining(force=false)
headers = @last_header headers = @last_header
if @last_header == nil || force if @last_header == nil || force
headers = request(:head, "/", {}, api_version, true, true, false) headers = head("/")
end end
return headers["X-RateLimit-Remaining"].to_i return headers["X-RateLimit-Remaining"].to_i
end end
Expand Down

0 comments on commit 92bc4c3

Please sign in to comment.