Represents a Twitter user
Used as factory method callback
# File lib/twitter/model.rb, line 284 def attributes; @@ATTRIBUTES; end
Provides access to the Featured Twitter API via the Twitter4R Model interface.
The following lines of code are equivalent to each other:
users1 = Twitter::User.features(client) users2 = client.featured(:users)
where users1 and users2 would be logically equivalent.
# File lib/twitter/extras.rb, line 35 def featured(client) client.featured(:users) end
Returns user model object with given id using the configuration and credentials of the client object passed in.
You can pass in either the user's unique integer ID or the user's screen name.
# File lib/twitter/model.rb, line 291 def find(id, client) client.user(id) end
Override of ModelMixin#bless method.
Adds followers instance method when user object represents authenticated user. Otherwise just do basic bless.
This permits applications using Twitter4R to write Rubyish code like this:
followers = user.followers if user.is_me?
Or:
followers = user.followers if user.respond_to?(:followers)
# File lib/twitter/model.rb, line 306 def bless(client) basic_bless(client) self.instance_eval(%{ self.class.send(:include, Twitter::AuthenticatedUserMixin) }) if self.is_me? and not self.respond_to?(:followers) self end
Returns an Array of user objects that represents the authenticated user's friends on Twitter.
# File lib/twitter/model.rb, line 332 def friends @client.user(@id, :friends) end
Returns whether this Twitter::User model object represents the authenticated user of the client that blessed it.
# File lib/twitter/model.rb, line 317 def is_me? # TODO: Determine whether we should cache this or not? # Might be dangerous to do so, but do we want to support # the edge case where this would cause a problem? i.e. # changing authenticated user after initial use of # authenticated API. # TBD: To cache or not to cache. That is the question! # Since this is an implementation detail we can leave this for # subsequent 0.2.x releases. It doesn't have to be decided before # the 0.2.0 launch. @screen_name == @client.instance_eval("@login") end
Generated with the Darkfish Rdoc Generator 2.