Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update documentation [ci skip]

  • Loading branch information...
commit 5a3c2964665a280058aec1e4fcf320b621f939c4 1 parent b6c401b
Erik Michaels-Ober authored
3  lib/twitter/arguments.rb
View
@@ -2,6 +2,9 @@ module Twitter
class Arguments < Array
attr_reader :options
+ # Initializes a new Arguments object
+ #
+ # @return [Twitter::Arguments]
def initialize(args)
@options = args.last.is_a?(::Hash) ? args.pop : {}
super(args)
4 lib/twitter/base.rb
View
@@ -58,6 +58,7 @@ def uri_attr_reader(*attrs)
end
end
+ # Define display_uri attribute methods
def display_uri_attr_reader
define_attribute_method(:display_url)
alias_method(:display_uri, :display_url)
@@ -101,7 +102,8 @@ def define_attribute_method(key1, klass=nil, key2=nil)
# Dynamically define a predicate method for an attribute
#
- # @param key [Symbol]
+ # @param key1 [Symbol]
+ # @param key2 [Symbol]
def define_predicate_method(key1, key2=key1)
define_method(:"#{key1}?") do
!!@attrs[key2]
1  lib/twitter/client.rb
View
@@ -28,6 +28,7 @@ def user_token?
!!(access_token && access_token_secret)
end
+ # @return [String]
def user_agent
@user_agent ||= "Twitter Ruby Gem #{Twitter::Version}"
end
1  lib/twitter/creatable.rb
View
@@ -13,6 +13,7 @@ def created_at
end
memoize :created_at
+ # @return [Boolean]
def created?
!!@attrs[:created_at]
end
2  lib/twitter/enumerable.rb
View
@@ -3,7 +3,7 @@ module Enumerable
include ::Enumerable
# @return [Enumerator]
- def each(start = 0, &block)
+ def each(start=0, &block)
return to_enum(:each) unless block_given?
Array(@collection[start..-1]).each do |element|
yield element
7 lib/twitter/factory.rb
View
@@ -3,6 +3,13 @@ class Factory
class << self
+ # Construct a new object
+ #
+ # @param method [Symbol]
+ # @param klass [Class]
+ # @param attrs [Hash]
+ # @raise [IndexError] Error raised when supplied argument is missing a key.
+ # @return [Twitter::Base]
def new(method, klass, attrs={})
type = attrs.fetch(method.to_sym)
const_name = type.gsub(/\/(.?)/){"::#{$1.upcase}"}.gsub(/(?:^|_)(.)/){$1.upcase}
2  lib/twitter/geo_factory.rb
View
@@ -10,7 +10,7 @@ class << self
# Construct a new geo object
#
# @param attrs [Hash]
- # @raise [ArgumentError] Error raised when supplied argument is missing a :type key.
+ # @raise [IndexError] Error raised when supplied argument is missing a :type key.
# @return [Twitter::Geo]
def new(attrs={})
super(:type, Geo, attrs)
4 lib/twitter/geo_results.rb
View
@@ -10,7 +10,7 @@ class GeoResults
class << self
- # Construct a new SearchResults object from a response hash
+ # Construct a new GeoResults object from a response hash
#
# @param response [Hash]
# @return [Twitter::Base]
@@ -20,7 +20,7 @@ def from_response(response={})
end
- # Initializes a new SearchResults object
+ # Initializes a new GeoResults object
#
# @param attrs [Hash]
# @return [Twitter::GeoResults]
2  lib/twitter/media_factory.rb
View
@@ -9,7 +9,7 @@ class << self
# Construct a new media object
#
# @param attrs [Hash]
- # @raise [ArgumentError] Error raised when supplied argument is missing a :type key.
+ # @raise [IndexError] Error raised when supplied argument is missing a :type key.
# @return [Twitter::Media]
def new(attrs={})
super(:type, Media, attrs)
4 lib/twitter/null_object.rb
View
@@ -1,18 +1,22 @@
module Twitter
class NullObject
+ # @return [TrueClass] This method always returns true.
def nil?
true
end
+ # @return [Twitter::NullObject] This method always returns self.
def method_missing(*args, &block)
self
end
+ # @return [TrueClass] This method always returns true.
def respond_to?(method_name, include_private=false)
true
end if RUBY_VERSION < "1.9"
+ # @return [TrueClass] This method always returns true.
def respond_to_missing?(method_name, include_private=false)
true
end if RUBY_VERSION >= "1.9"
14 lib/twitter/rest/api/oauth.rb
View
@@ -40,12 +40,20 @@ def invalidate_token(access_token)
object_from_response(Twitter::Token, :post, "/oauth2/invalidate_token", :access_token => access_token)
end
+ # Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials.
+ #
+ # @see https://dev.twitter.com/docs/api/1.1/post/oauth2/invalidate_token
+ # @rate_limited No
+ # @authentication Required
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
+ # @return [String] The token string.
def reverse_token
conn = connection.dup
- conn.builder.swap 4, Twitter::REST::Response::ParseErrorJson
- conn.post('/oauth/request_token?x_auth_mode=reverse_auth') do |request|
+ conn.builder.swap(4, Twitter::REST::Response::ParseErrorJson)
+ response = conn.post('/oauth/request_token?x_auth_mode=reverse_auth') do |request|
request.headers[:authorization] = oauth_auth_header(:post, 'https://api.twitter.com/oauth/request_token', :x_auth_mode => 'reverse_auth').to_s
- end.body
+ end
+ response.body
end
end
8 lib/twitter/streaming/client.rb
View
@@ -9,28 +9,36 @@ module Streaming
class Client < Twitter::Client
attr_writer :connection
+ # Initializes a new Client object
+ #
+ # @return [Twitter::Streaming::Client]
def initialize(options={}, &block)
super
@connection = Streaming::Connection.new
end
+ # @yield [Twitter::Tweet] A stream of tweets.
def filter(options={}, &block)
request(:get, 'https://stream.twitter.com:443/1.1/statuses/filter.json', options, &block)
end
+ # @yield [Twitter::Tweet] A stream of tweets.
def firehose(options={}, &block)
request(:get, 'https://stream.twitter.com:443/1.1/statuses/firehose.json', options, &block)
end
+ # @yield [Twitter::Tweet] A stream of tweets.
def sample(options={}, &block)
request(:get, 'https://stream.twitter.com:443/1.1/statuses/sample.json', options, &block)
end
+ # @yield [Twitter::Tweet] A stream of tweets.
def site(*args, &block)
arguments = Arguments.new(args)
request(:get, 'https://sitestream.twitter.com:443/1.1/site.json', arguments.options.merge(:follow => arguments.join(',')), &block)
end
+ # @yield [Twitter::Tweet] A stream of tweets.
def user(options={}, &block)
request(:get, 'https://userstream.twitter.com:443/1.1/user.json', options, &block)
end
4 lib/twitter/streaming/response.rb
View
@@ -3,6 +3,10 @@
module Twitter
module Streaming
class Response
+
+ # Initializes a new Response object
+ #
+ # @return [Twitter::Streaming::Response]
def initialize(&block)
@block = block
@parser = Http::Parser.new(self)
4 lib/twitter/trend_results.rb
View
@@ -15,7 +15,7 @@ class TrendResults
class << self
- # Construct a new SearchResults object from a response hash
+ # Construct a new TrendResults object from a response hash
#
# @param response [Hash]
# @return [Twitter::Base]
@@ -25,7 +25,7 @@ def from_response(response={})
end
- # Initializes a new SearchResults object
+ # Initializes a new TrendResults object
#
# @param attrs [Hash]
# @return [Twitter::TrendResults]
1  lib/twitter/user.rb
View
@@ -70,6 +70,7 @@ def profile_banner_uri_https(size=:web)
end
alias profile_banner_url_https profile_banner_uri_https
+ # @return [Boolean]
def profile_banner_uri?
!!@attrs[:profile_banner_url]
end
Please sign in to comment.
Something went wrong with that request. Please try again.