-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for the new rate_limit_status method.
- Loading branch information
1 parent
27745af
commit 2b5325b
Showing
5 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Twitter | ||
class RateLimitStatus | ||
include EasyClassMaker | ||
|
||
attributes :reset_time_in_seconds, :reset_time, :remaining_hits, :hourly_limit | ||
|
||
class << self | ||
# Creates a new rate limi status from a piece of xml | ||
def new_from_xml(xml) | ||
RateLimitStatus.new do |s| | ||
s.reset_time_in_seconds = xml.at('reset-time-in-seconds').inner_html.to_i | ||
s.reset_time = Time.parse xml.at('reset-time').inner_html | ||
s.remaining_hits = xml.at('remaining-hits').inner_html.to_i | ||
s.hourly_limit = xml.at('hourly-limit').inner_html.to_i | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<hash> | ||
<hourly-limit type="integer">20</hourly-limit> | ||
<reset-time-in-seconds type="integer">1214757610</reset-time-in-seconds> | ||
<reset-time type="datetime">2008-06-29T16:40:10+00:00</reset-time> | ||
<remaining-hits type="integer">5</remaining-hits> | ||
</hash> |