Module: Twitter::Client::Tweets
- Included in:
- Twitter::Client
- Defined in:
- lib/twitter/client/tweets.rb
Overview
Defines methods related to tweets
Instance Method Summary collapse
-
#oembed(id_or_url, options = {}) ⇒ Object
Returns an oEmbed version of a single status, specified by ID or url to the tweet.
-
#retweet(id, options = {}) ⇒ Twitter::Status
Retweets a tweet.
-
#retweeters_of(id, options = {}) ⇒ Array
Show up to 100 users who retweeted the status.
-
#retweets(id, options = {}) ⇒ Array<Twitter::Status>
Returns up to 100 of the first retweets of a given tweet.
-
#status(id, options = {}) ⇒ Twitter::Status
Returns a single status, specified by ID.
-
#status_destroy(id, options = {}) ⇒ Twitter::Status
Destroys the specified status.
-
#update(status, options = {}) ⇒ Twitter::Status
Updates the authenticating user's status.
-
#update_with_media(status, image, options = {}) ⇒ Twitter::Status
Updates with media the authenticating user's status.
Instance Method Details
#oembed(id_or_url, options = {}) ⇒ Object
Returns an oEmbed version of a single status, specified by ID or url to the tweet
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/twitter/client/tweets.rb', line 88 def (id_or_url, ={}) case id_or_url when Integer id = id_or_url = get("/1/statuses/oembed.json?id=#{id}", ) when String url = id_or_url escaped_url = URI.escape(url, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) = get("/1/statuses/oembed.json?url=#{escaped_url}", ) end Twitter::OEmbed.new() end |
#retweet(id, options = {}) ⇒ Twitter::Status
Retweets a tweet
132 133 134 135 136 137 |
# File 'lib/twitter/client/tweets.rb', line 132 def retweet(id, ={}) new_status = post("/1/statuses/retweet/#{id}.json", ) orig_status = new_status.delete('retweeted_status') orig_status['retweeted_status'] = new_status Twitter::Status.new(orig_status) end |
#retweeters_of(id, options = {}) ⇒ Array
Show up to 100 users who retweeted the status
26 27 28 29 30 31 32 33 34 |
# File 'lib/twitter/client/tweets.rb', line 26 def retweeters_of(id, ={}) if ids_only = !!.delete(:ids_only) get("/1/statuses/#{id}/retweeted_by/ids.json", ) else get("/1/statuses/#{id}/retweeted_by.json", ).map do |user| Twitter::User.new(user) end end end |
#retweets(id, options = {}) ⇒ Array<Twitter::Status>
Returns up to 100 of the first retweets of a given tweet
50 51 52 53 54 |
# File 'lib/twitter/client/tweets.rb', line 50 def retweets(id, ={}) get("/1/statuses/retweets/#{id}.json", ).map do |status| Twitter::Status.new(status) end end |
#status(id, options = {}) ⇒ Twitter::Status
Returns a single status, specified by ID
68 69 70 71 |
# File 'lib/twitter/client/tweets.rb', line 68 def status(id, ={}) status = get("/1/statuses/show/#{id}.json", ) Twitter::Status.new(status) end |
#status_destroy(id, options = {}) ⇒ Twitter::Status
The authenticating user must be the author of the specified status.
Destroys the specified status
114 115 116 117 |
# File 'lib/twitter/client/tweets.rb', line 114 def status_destroy(id, ={}) status = delete("/1/statuses/destroy/#{id}.json", ) Twitter::Status.new(status) end |
#update(status, options = {}) ⇒ Twitter::Status
A status update with text identical to the authenticating user's current status will be ignored to prevent duplicates.
Updates the authenticating user's status
158 159 160 161 |
# File 'lib/twitter/client/tweets.rb', line 158 def update(status, ={}) status = post("/1/statuses/update.json", .merge(:status => status)) Twitter::Status.new(status) end |
#update_with_media(status, image, options = {}) ⇒ Twitter::Status
A status update with text/media identical to the authenticating user's current status will NOT be ignored
Updates with media the authenticating user's status
184 185 186 187 |
# File 'lib/twitter/client/tweets.rb', line 184 def update_with_media(status, image, ={}) status = post("/1/statuses/update_with_media.json", .merge('media[]' => image, 'status' => status), :endpoint => media_endpoint) Twitter::Status.new(status) end |