Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

1000 lines (566 sloc) 46.877 kb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
Module: Octokit
&mdash;
</title>
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
hasFrames = window.top.frames.main ? true : false;
relpath = '';
framesUrl = "frames.html#!Octokit.html";
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<div id="header">
<div id="menu">
<a href="_index.html">Index (O)</a> &raquo;
<span class="title">Octokit</span>
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="class_list.html">
Class List
</a>
<a class="full_list_link" id="method_list_link"
href="method_list.html">
Method List
</a>
<a class="full_list_link" id="file_list_link"
href="file_list.html">
File List
</a>
</div>
<div class="clear"></div>
</div>
<iframe id="search_frame"></iframe>
<div id="content"><h1>Module: Octokit
</h1>
<dl class="box">
<dt class="r1">Extended by:</dt>
<dd class="r1"><span class='object_link'><a href="Octokit/Configurable.html" title="Octokit::Configurable (module)">Configurable</a></span></dd>
<dt class="r2 last">Defined in:</dt>
<dd class="r2 last">lib/octokit.rb<span class="defines">,<br />
lib/octokit/user.rb,<br /> lib/octokit/gist.rb,<br /> lib/octokit/error.rb,<br /> lib/octokit/client.rb,<br /> lib/octokit/default.rb,<br /> lib/octokit/version.rb,<br /> lib/octokit/client/say.rb,<br /> lib/octokit/repository.rb,<br /> lib/octokit/rate_limit.rb,<br /> lib/octokit/client/refs.rb,<br /> lib/octokit/client/meta.rb,<br /> lib/octokit/client/stats.rb,<br /> lib/octokit/client/hooks.rb,<br /> lib/octokit/configurable.rb,<br /> lib/octokit/organization.rb,<br /> lib/octokit/client/pages.rb,<br /> lib/octokit/client/feeds.rb,<br /> lib/octokit/client/gists.rb,<br /> lib/octokit/client/users.rb,<br /> lib/octokit/client/search.rb,<br /> lib/octokit/client/emojis.rb,<br /> lib/octokit/client/events.rb,<br /> lib/octokit/client/issues.rb,<br /> lib/octokit/client/labels.rb,<br /> lib/octokit/client/commits.rb,<br /> lib/octokit/client/objects.rb,<br /> lib/octokit/authentication.rb,<br /> lib/octokit/client/contents.rb,<br /> lib/octokit/client/markdown.rb,<br /> lib/octokit/client/statuses.rb,<br /> lib/octokit/client/releases.rb,<br /> lib/octokit/client/downloads.rb,<br /> lib/octokit/client/gitignore.rb,<br /> lib/octokit/client/milestones.rb,<br /> lib/octokit/client/rate_limit.rb,<br /> lib/octokit/client/deployments.rb,<br /> lib/octokit/client/repositories.rb,<br /> lib/octokit/client/legacy_search.rb,<br /> lib/octokit/client/pull_requests.rb,<br /> lib/octokit/client/notifications.rb,<br /> lib/octokit/client/organizations.rb,<br /> lib/octokit/client/authorizations.rb,<br /> lib/octokit/client/pub_sub_hubbub.rb,<br /> lib/octokit/client/service_status.rb,<br /> lib/octokit/client/commit_comments.rb</span>
</dd>
</dl>
<div class="clear"></div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Ruby toolkit for the GitHub API</p>
</div>
</div>
<div class="tags">
</div><h2>Defined Under Namespace</h2>
<p class="children">
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Octokit/Authentication.html" title="Octokit::Authentication (module)">Authentication</a></span>, <span class='object_link'><a href="Octokit/Configurable.html" title="Octokit::Configurable (module)">Configurable</a></span>, <span class='object_link'><a href="Octokit/Default.html" title="Octokit::Default (module)">Default</a></span>
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Octokit/AbuseDetected.html" title="Octokit::AbuseDetected (class)">AbuseDetected</a></span>, <span class='object_link'><a href="Octokit/ApplicationCredentialsRequired.html" title="Octokit::ApplicationCredentialsRequired (class)">ApplicationCredentialsRequired</a></span>, <span class='object_link'><a href="Octokit/BadGateway.html" title="Octokit::BadGateway (class)">BadGateway</a></span>, <span class='object_link'><a href="Octokit/BadRequest.html" title="Octokit::BadRequest (class)">BadRequest</a></span>, <span class='object_link'><a href="Octokit/Client.html" title="Octokit::Client (class)">Client</a></span>, <span class='object_link'><a href="Octokit/ClientError.html" title="Octokit::ClientError (class)">ClientError</a></span>, <span class='object_link'><a href="Octokit/Conflict.html" title="Octokit::Conflict (class)">Conflict</a></span>, <span class='object_link'><a href="Octokit/Error.html" title="Octokit::Error (class)">Error</a></span>, <span class='object_link'><a href="Octokit/Forbidden.html" title="Octokit::Forbidden (class)">Forbidden</a></span>, <span class='object_link'><a href="Octokit/Gist.html" title="Octokit::Gist (class)">Gist</a></span>, <span class='object_link'><a href="Octokit/InternalServerError.html" title="Octokit::InternalServerError (class)">InternalServerError</a></span>, <span class='object_link'><a href="Octokit/MethodNotAllowed.html" title="Octokit::MethodNotAllowed (class)">MethodNotAllowed</a></span>, <span class='object_link'><a href="Octokit/MissingContentType.html" title="Octokit::MissingContentType (class)">MissingContentType</a></span>, <span class='object_link'><a href="Octokit/NotAcceptable.html" title="Octokit::NotAcceptable (class)">NotAcceptable</a></span>, <span class='object_link'><a href="Octokit/NotFound.html" title="Octokit::NotFound (class)">NotFound</a></span>, <span class='object_link'><a href="Octokit/NotImplemented.html" title="Octokit::NotImplemented (class)">NotImplemented</a></span>, <span class='object_link'><a href="Octokit/OneTimePasswordRequired.html" title="Octokit::OneTimePasswordRequired (class)">OneTimePasswordRequired</a></span>, <span class='object_link'><a href="Octokit/Organization.html" title="Octokit::Organization (class)">Organization</a></span>, <span class='object_link'><a href="Octokit/RateLimit.html" title="Octokit::RateLimit (class)">RateLimit</a></span>, <span class='object_link'><a href="Octokit/Repository.html" title="Octokit::Repository (class)">Repository</a></span>, <span class='object_link'><a href="Octokit/ServerError.html" title="Octokit::ServerError (class)">ServerError</a></span>, <span class='object_link'><a href="Octokit/ServiceUnavailable.html" title="Octokit::ServiceUnavailable (class)">ServiceUnavailable</a></span>, <span class='object_link'><a href="Octokit/TooManyLoginAttempts.html" title="Octokit::TooManyLoginAttempts (class)">TooManyLoginAttempts</a></span>, <span class='object_link'><a href="Octokit/TooManyRequests.html" title="Octokit::TooManyRequests (class)">TooManyRequests</a></span>, <span class='object_link'><a href="Octokit/Unauthorized.html" title="Octokit::Unauthorized (class)">Unauthorized</a></span>, <span class='object_link'><a href="Octokit/UnprocessableEntity.html" title="Octokit::UnprocessableEntity (class)">UnprocessableEntity</a></span>, <span class='object_link'><a href="Octokit/UnsupportedMediaType.html" title="Octokit::UnsupportedMediaType (class)">UnsupportedMediaType</a></span>, <span class='object_link'><a href="Octokit/User.html" title="Octokit::User (class)">User</a></span>
</p>
<h2>Constant Summary</h2>
<dl class="constants">
<dt id="MAJOR-constant" class="">MAJOR =
<div class="docstring">
<div class="discussion">
<p>Current major release.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Integer</tt>)</span>
</li>
</ul>
</div>
</dt>
<dd><pre class="code"><span class='int'>3</span></pre></dd>
<dt id="MINOR-constant" class="">MINOR =
<div class="docstring">
<div class="discussion">
<p>Current minor release.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Integer</tt>)</span>
</li>
</ul>
</div>
</dt>
<dd><pre class="code"><span class='int'>7</span></pre></dd>
<dt id="PATCH-constant" class="">PATCH =
<div class="docstring">
<div class="discussion">
<p>Current patch level.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Integer</tt>)</span>
</li>
</ul>
</div>
</dt>
<dd><pre class="code"><span class='int'>1</span></pre></dd>
<dt id="VERSION-constant" class="">VERSION =
<div class="docstring">
<div class="discussion">
<p>Full release version.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
</li>
</ul>
</div>
</dt>
<dd><pre class="code"><span class='lbracket'>[</span><span class='const'>MAJOR</span><span class='comma'>,</span> <span class='const'>MINOR</span><span class='comma'>,</span> <span class='const'>PATCH</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>.</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
</dl>
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#limit%3D-instance_method" title="#limit= (instance method)">- (Fixnum) <strong>limit</strong> </a>
</span>
<span class="note title writeonly">writeonly</span>
<span class="summary_desc"><div class='inline'><p>Max tries per rate limit period.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#remaining%3D-instance_method" title="#remaining= (instance method)">- (Fixnum) <strong>remaining</strong> </a>
</span>
<span class="note title writeonly">writeonly</span>
<span class="summary_desc"><div class='inline'><p>Remaining tries per rate limit period.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#resets_at%3D-instance_method" title="#resets_at= (instance method)">- (Time) <strong>resets_at</strong> </a>
</span>
<span class="note title writeonly">writeonly</span>
<span class="summary_desc"><div class='inline'><p>Indicates when rate limit resets.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#resets_in%3D-instance_method" title="#resets_in= (instance method)">- (Fixnum) <strong>resets_in</strong> </a>
</span>
<span class="note title writeonly">writeonly</span>
<span class="summary_desc"><div class='inline'><p>Number of seconds when rate limit resets.</p>
</div></span>
</li>
</ul>
<h3 class="inherited">Attributes included from <span class='object_link'><a href="Octokit/Configurable.html" title="Octokit::Configurable (module)">Configurable</a></span></h3>
<p class="inherited"><span class='object_link'><a href="Octokit/Configurable.html#access_token-instance_method" title="Octokit::Configurable#access_token (method)">#access_token</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#api_endpoint-instance_method" title="Octokit::Configurable#api_endpoint (method)">#api_endpoint</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#auto_paginate-instance_method" title="Octokit::Configurable#auto_paginate (method)">#auto_paginate</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#client_id-instance_method" title="Octokit::Configurable#client_id (method)">#client_id</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#client_secret-instance_method" title="Octokit::Configurable#client_secret (method)">#client_secret</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#connection_options-instance_method" title="Octokit::Configurable#connection_options (method)">#connection_options</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#default_media_type-instance_method" title="Octokit::Configurable#default_media_type (method)">#default_media_type</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#login-instance_method" title="Octokit::Configurable#login (method)">#login</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#middleware-instance_method" title="Octokit::Configurable#middleware (method)">#middleware</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#netrc-instance_method" title="Octokit::Configurable#netrc (method)">#netrc</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#netrc_file-instance_method" title="Octokit::Configurable#netrc_file (method)">#netrc_file</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#password%3D-instance_method" title="Octokit::Configurable#password= (method)">#password</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#per_page-instance_method" title="Octokit::Configurable#per_page (method)">#per_page</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#proxy-instance_method" title="Octokit::Configurable#proxy (method)">#proxy</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#user_agent-instance_method" title="Octokit::Configurable#user_agent (method)">#user_agent</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#web_endpoint-instance_method" title="Octokit::Configurable#web_endpoint (method)">#web_endpoint</a></span></p>
<h2>
Class Method Summary
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#client-class_method" title="client (class method)">+ (Octokit::Client) <strong>client</strong> </a>
</span>
<span class="summary_desc"><div class='inline'><p>API client based on configured options <span class='object_link'><a href="Octokit/Configurable.html" title="Octokit::Configurable (module)">Configurable</a></span>.</p>
</div></span>
</li>
</ul>
<h2>
Instance Method Summary
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#respond_to%3F-instance_method" title="#respond_to? (instance method)">- (Boolean) <strong>respond_to?</strong>(method_name, include_private = false) </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#respond_to_missing%3F-instance_method" title="#respond_to_missing? (instance method)">- (Boolean) <strong>respond_to_missing?</strong>(method_name, include_private = false) </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
</ul>
<h3 class="inherited">Methods included from <span class='object_link'><a href="Octokit/Configurable.html" title="Octokit::Configurable (module)">Configurable</a></span></h3>
<p class="inherited"><span class='object_link'><a href="Octokit/Configurable.html#configure-instance_method" title="Octokit::Configurable#configure (method)">configure</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#keys-class_method" title="Octokit::Configurable.keys (method)">keys</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#netrc%3F-instance_method" title="Octokit::Configurable#netrc? (method)">netrc?</a></span>, <span class='object_link'><a href="Octokit/Configurable.html#reset%21-instance_method" title="Octokit::Configurable#reset! (method)">reset!</a></span></p>
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
<span id=""></span>
<div class="method_details first">
<h3 class="signature first" id="limit=-instance_method">
- (<tt>Fixnum</tt>) <strong>limit=</strong>(value) <span class="extras">(writeonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns Max tries per rate limit period</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Fixnum</tt>)</span>
&mdash;
<div class='inline'><p>Max tries per rate limit period</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/octokit/rate_limit.rb', line 15</span>
<span class='kw'>class</span> <span class='const'>RateLimit</span> <span class='op'>&lt;</span> <span class='const'>Struct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:limit</span><span class='comma'>,</span> <span class='symbol'>:remaining</span><span class='comma'>,</span> <span class='symbol'>:resets_at</span><span class='comma'>,</span> <span class='symbol'>:resets_in</span><span class='rparen'>)</span>
<span class='comment'># Get rate limit info from HTTP response
</span> <span class='comment'>#
</span> <span class='comment'># @param response [#headers] HTTP response
</span> <span class='comment'># @return [RateLimit]
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_response'>from_response</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
<span class='id identifier rubyid_info'>info</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span>
<span class='kw'>if</span> <span class='id identifier rubyid_response'>response</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_limit'>limit</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Limit</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_remaining'>remaining</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Remaining</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_at'>resets_at</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Reset</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='rparen'>)</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_in'>resets_in</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='lparen'>(</span><span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_at'>resets_at</span> <span class='op'>-</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_info'>info</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id=""></span>
<div class="method_details ">
<h3 class="signature " id="remaining=-instance_method">
- (<tt>Fixnum</tt>) <strong>remaining=</strong>(value) <span class="extras">(writeonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns Remaining tries per rate limit period</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Fixnum</tt>)</span>
&mdash;
<div class='inline'><p>Remaining tries per rate limit period</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/octokit/rate_limit.rb', line 15</span>
<span class='kw'>class</span> <span class='const'>RateLimit</span> <span class='op'>&lt;</span> <span class='const'>Struct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:limit</span><span class='comma'>,</span> <span class='symbol'>:remaining</span><span class='comma'>,</span> <span class='symbol'>:resets_at</span><span class='comma'>,</span> <span class='symbol'>:resets_in</span><span class='rparen'>)</span>
<span class='comment'># Get rate limit info from HTTP response
</span> <span class='comment'>#
</span> <span class='comment'># @param response [#headers] HTTP response
</span> <span class='comment'># @return [RateLimit]
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_response'>from_response</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
<span class='id identifier rubyid_info'>info</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span>
<span class='kw'>if</span> <span class='id identifier rubyid_response'>response</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_limit'>limit</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Limit</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_remaining'>remaining</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Remaining</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_at'>resets_at</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Reset</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='rparen'>)</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_in'>resets_in</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='lparen'>(</span><span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_at'>resets_at</span> <span class='op'>-</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_info'>info</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id=""></span>
<div class="method_details ">
<h3 class="signature " id="resets_at=-instance_method">
- (<tt>Time</tt>) <strong>resets_at=</strong>(value) <span class="extras">(writeonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns Indicates when rate limit resets</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Time</tt>)</span>
&mdash;
<div class='inline'><p>Indicates when rate limit resets</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/octokit/rate_limit.rb', line 15</span>
<span class='kw'>class</span> <span class='const'>RateLimit</span> <span class='op'>&lt;</span> <span class='const'>Struct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:limit</span><span class='comma'>,</span> <span class='symbol'>:remaining</span><span class='comma'>,</span> <span class='symbol'>:resets_at</span><span class='comma'>,</span> <span class='symbol'>:resets_in</span><span class='rparen'>)</span>
<span class='comment'># Get rate limit info from HTTP response
</span> <span class='comment'>#
</span> <span class='comment'># @param response [#headers] HTTP response
</span> <span class='comment'># @return [RateLimit]
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_response'>from_response</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
<span class='id identifier rubyid_info'>info</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span>
<span class='kw'>if</span> <span class='id identifier rubyid_response'>response</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_limit'>limit</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Limit</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_remaining'>remaining</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Remaining</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_at'>resets_at</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Reset</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='rparen'>)</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_in'>resets_in</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='lparen'>(</span><span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_at'>resets_at</span> <span class='op'>-</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_info'>info</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id=""></span>
<div class="method_details ">
<h3 class="signature " id="resets_in=-instance_method">
- (<tt>Fixnum</tt>) <strong>resets_in=</strong>(value) <span class="extras">(writeonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns Number of seconds when rate limit resets</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Fixnum</tt>)</span>
&mdash;
<div class='inline'><p>Number of seconds when rate limit resets</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/octokit/rate_limit.rb', line 15</span>
<span class='kw'>class</span> <span class='const'>RateLimit</span> <span class='op'>&lt;</span> <span class='const'>Struct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:limit</span><span class='comma'>,</span> <span class='symbol'>:remaining</span><span class='comma'>,</span> <span class='symbol'>:resets_at</span><span class='comma'>,</span> <span class='symbol'>:resets_in</span><span class='rparen'>)</span>
<span class='comment'># Get rate limit info from HTTP response
</span> <span class='comment'>#
</span> <span class='comment'># @param response [#headers] HTTP response
</span> <span class='comment'># @return [RateLimit]
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_response'>from_response</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
<span class='id identifier rubyid_info'>info</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span>
<span class='kw'>if</span> <span class='id identifier rubyid_response'>response</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_limit'>limit</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Limit</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_remaining'>remaining</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Remaining</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_at'>resets_at</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_at'>at</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>X-RateLimit-Reset</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='rparen'>)</span>
<span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_in'>resets_in</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='lparen'>(</span><span class='id identifier rubyid_info'>info</span><span class='period'>.</span><span class='id identifier rubyid_resets_at'>resets_at</span> <span class='op'>-</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_info'>info</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="class_method_details" class="method_details_list">
<h2>Class Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="client-class_method">
+ (<tt><span class='object_link'><a href="Octokit/Client.html" title="Octokit::Client (class)">Octokit::Client</a></span></tt>) <strong>client</strong>
</h3><div class="docstring">
<div class="discussion">
<p>API client based on configured options <span class='object_link'><a href="Octokit/Configurable.html" title="Octokit::Configurable (module)">Configurable</a></span></p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="Octokit/Client.html" title="Octokit::Client (class)">Octokit::Client</a></span></tt>)</span>
&mdash;
<div class='inline'><p>API wrapper</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
13
14
15
16</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/octokit.rb', line 13</span>
<span class='kw'>def</span> <span class='id identifier rubyid_client'>client</span>
<span class='ivar'>@client</span> <span class='op'>=</span> <span class='const'>Octokit</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='ivar'>@client</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@client</span><span class='period'>.</span><span class='id identifier rubyid_same_options?'>same_options?</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
<span class='ivar'>@client</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="respond_to?-instance_method">
- (<tt>Boolean</tt>) <strong>respond_to?</strong>(method_name, include_private = false)
</h3><div class="docstring">
<div class="discussion">
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
21</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/octokit.rb', line 21</span>
<span class='kw'>def</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name'>method_name</span><span class='comma'>,</span> <span class='id identifier rubyid_include_private'>include_private</span><span class='op'>=</span><span class='kw'>false</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name'>method_name</span><span class='comma'>,</span> <span class='id identifier rubyid_include_private'>include_private</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='kw'>super</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="respond_to_missing?-instance_method">
- (<tt>Boolean</tt>) <strong>respond_to_missing?</strong>(method_name, include_private = false)
</h3><div class="docstring">
<div class="discussion">
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
19</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/octokit.rb', line 19</span>
<span class='kw'>def</span> <span class='id identifier rubyid_respond_to_missing?'>respond_to_missing?</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name'>method_name</span><span class='comma'>,</span> <span class='id identifier rubyid_include_private'>include_private</span><span class='op'>=</span><span class='kw'>false</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name'>method_name</span><span class='comma'>,</span> <span class='id identifier rubyid_include_private'>include_private</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Sat Feb 14 08:50:11 2015 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.8.7.4 (ruby-2.1.4).
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.