Class: Twitter::Status
- Inherits:
-
Object
- Object
- Twitter::Status
- Includes:
- ModelMixin
- Defined in:
- lib/twitter/model.rb
Overview
Represents a status posted to Twitter by a Twitter user.
Constant Summary collapse
- @@ATTRIBUTES =
[:id, :id_str, :text, :source, :truncated, :created_at, :user, :from_user, :to_user, :favorited, :in_reply_to_status_id, :in_reply_to_user_id, :in_reply_to_screen_name, :geo]
Class Method Summary collapse
-
.attributes ⇒ Object
Used as factory method callback.
-
.create(params) ⇒ Object
Creates a new status for the authenticated user of the given client context.
-
.find(id, client) ⇒ Object
Returns status model object with given status using the configuration and credentials of the client object passed in.
Instance Method Summary collapse
-
#reply(reply) ⇒ Object
Convenience method to allow client developers to not have to worry about setting the
in_reply_to_status_idattribute or prefixing the status text with thescreen_namebeing replied to. - #reply? ⇒ Boolean
Methods included from ModelMixin
Class Method Details
.attributes ⇒ Object
Used as factory method callback
347 |
# File 'lib/twitter/model.rb', line 347 def attributes; @@ATTRIBUTES; end |
.create(params) ⇒ Object
Creates a new status for the authenticated user of the given client context.
You MUST include a valid/authenticated client context in the given params argument.
For example: status = Twitter::Status.create( :text => 'I am shopping for flip flops', :client => client)
An ArgumentError will be raised if no valid client context is given in the params Hash. For example, status = Twitter::Status.create(:text => 'I am shopping for flip flops') The above line of code will raise an ArgumentError.
The same is true when you do not provide a :text key-value pair in the params argument given.
The Twitter::Status object returned after the status successfully updates on the Twitter server side is returned from this method.
376 377 378 379 380 381 |
# File 'lib/twitter/model.rb', line 376 def create(params) client, text = params[:client], params[:text] raise ArgumentError, 'Valid client context must be provided' unless client.is_a?(Twitter::Client) raise ArgumentError, 'Must provide text for the status to update' unless text.is_a?(String) client.status(:post, text) end |
.find(id, client) ⇒ Object
Returns status model object with given status using the configuration and credentials of the client object passed in.
351 352 353 |
# File 'lib/twitter/model.rb', line 351 def find(id, client) client.status(:get, id) end |
Instance Method Details
#reply(reply) ⇒ Object
Convenience method to allow client developers to not have to worry about
setting the in_reply_to_status_id attribute or prefixing the status
text with the screen_name being replied to.
391 392 393 394 395 |
# File 'lib/twitter/model.rb', line 391 def reply(reply) status_reply = "@#{user.screen_name} #{reply}" client.status(:reply, :status => status_reply, :in_reply_to_status_id => @id) end |
#reply? ⇒ Boolean
384 385 386 |
# File 'lib/twitter/model.rb', line 384 def reply? !!@in_reply_to_status_id end |