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, :text, :source, :truncated, :created_at, :user, :favorited, :in_reply_to_status_id, :in_reply_to_user_id, :in_reply_to_screen_name]
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
Methods included from ModelMixin
Class Method Details
.attributes ⇒ Object
Used as factory method callback
235 |
# File 'lib/twitter/model.rb', line 235 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.
264 265 266 267 268 269 |
# File 'lib/twitter/model.rb', line 264 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.
239 240 241 |
# File 'lib/twitter/model.rb', line 239 def find(id, client) client.status(:get, id) end |
Instance Method Details
#reply(status) ⇒ Object
276 277 278 |
# File 'lib/twitter/model.rb', line 276 def reply(status) client.status(:reply, :status => status, :in_reply_to_status_id => @id) end |
#reply? ⇒ Boolean
272 273 274 |
# File 'lib/twitter/model.rb', line 272 def reply? !!@in_reply_to_status_id end |