Parent

Class Index [+]

Quicksearch

TwitterAlert::Account

This represents the Twitter account you’ll use to send DMs from.

Public Class Methods

new(config) click to toggle source

Config is a hash that needs :user_name and :password keys.

    # File lib/twitter_alert/account.rb, line 7
 7:     def initialize config
 8:       # Load hash from yaml file in default location?
 9: 
10:       @username = config[:user_name]
11:       @password = config[:password]
12: 
13:       @client = Grackle::Client.new(
14:         :auth => {
15:           :type => :basic,
16:           :username => @username,
17:           :password => @password
18:         }
19:       )
20:     end

Public Instance Methods

announce(message) click to toggle source

Sends the text of message to all of the account’s followers. Message’s class should include the TwitterAlert::Alert Module.

Returns true if things went well and false if any DMs failed.

    # File lib/twitter_alert/account.rb, line 25
25:     def announce message
26:       followers.each do |follower|
27:         begin
28:           @client.direct_messages.new! :user_id => follower, :text => message.text
29:         rescue Grackle::TwitterError => e
30:           message.add_failed_announcement follower, e.message
31:         end
32:       end
33: 
34:       message.mark_sent
35:     end
followers() click to toggle source

Returns an array of ids of all the followers of the account.

    # File lib/twitter_alert/account.rb, line 38
38:     def followers
39:       @client.followers.ids?
40:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.