Included Modules


Represents a direct message on Twitter between Twitter users.

Public Class Methods

attributes() click to toggle source

Used as factory method callback

     # File lib/twitter/model.rb, line 296
296:       def attributes; @@ATTRIBUTES; end
create(params) click to toggle source

Creates a new direct message from 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::Message.create(
   :text => 'I am shopping for flip flops',
   :recipient => 'anotherlogin',
   :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 any of the following key-value pairs in the params argument given:

  • text - the String that will be the message text to send to user

  • recipient - the user ID, screen_name or Twitter::User object representation of the recipient of the direct message

The Twitter::Message object returned after the direct message is successfully sent on the Twitter server side is returned from this method.

     # File lib/twitter/model.rb, line 330
330:       def create(params)
331:         client, text, recipient = params[:client], params[:text], params[:recipient]
332:         raise ArgumentError, 'Valid client context must be given' unless client.is_a?(Twitter::Client)
333:         raise ArgumentError, 'Message text must be supplied to send direct message' unless text.is_a?(String)
334:         raise ArgumentError, 'Recipient user must be specified to send direct message' unless [Twitter::User, Integer, String].member?(recipient.class)
335:         client.message(:post, text, recipient)
336:       end
find(id, client) click to toggle source

Raises NotImplementedError because currently Twitter doesn’t provide a facility to retrieve one message by unique ID.

     # File lib/twitter/model.rb, line 301
301:       def find(id, client)
302:         raise NotImplementedError, 'Twitter has yet to implement a REST API for this.  This is not a Twitter4R library limitation.'
303:       end

Protected Instance Methods

init() click to toggle source

Constructor callback

     # File lib/twitter/model.rb, line 341
341:       def init
342:         @sender = if @sender.is_a?(Hash)
343:         @recipient = if @recipient.is_a?(Hash)
344:         @created_at = Time.parse(@created_at) if @created_at.is_a?(String)
345:       end

Disabled; run with --debug to generate this.


Generated with the Darkfish Rdoc Generator 1.1.6.