Class: SocialBee::Twi
- Inherits:
-
Object
- Object
- SocialBee::Twi
- Includes:
- Twitter, YAML
- Defined in:
- lib/social-bee/twi.rb
Instance Method Summary collapse
- #client(token, secret) ⇒ Object
- #get_friends(token, secret) ⇒ Object
-
#initialize(p = {}) ⇒ Twi
constructor
A new instance of Twi.
- #say_friends(message, token, secret) ⇒ Object
- #say_private(to, message, token, secret) ⇒ Object
- #say_public(message, token, secret) ⇒ Object
Constructor Details
#initialize(p = {}) ⇒ Twi
Returns a new instance of Twi.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/social-bee/twi.rb', line 9 def initialize(p={}) raise 'Undefined config file' unless @config = YAML.load_file(Rails.root + p[:config])[Rails.env] Twitter.configure do |config| raise 'Undefined consumer key' unless config.consumer_key = @config['app_key'] raise 'Undefined consumer secret' unless config.consumer_secret = @config['app_secret'] end end |
Instance Method Details
#client(token, secret) ⇒ Object
20 21 22 |
# File 'lib/social-bee/twi.rb', line 20 def client( token, secret ) Twitter::Client.new( :oauth_token => token, :oauth_token_secret => secret ) end |
#get_friends(token, secret) ⇒ Object
39 40 41 |
# File 'lib/social-bee/twi.rb', line 39 def get_friends( token, secret ) client( token, secret ).follower_ids.ids end |
#say_friends(message, token, secret) ⇒ Object
33 34 35 36 37 |
# File 'lib/social-bee/twi.rb', line 33 def say_friends( , token, secret ) get_friends( token, secret ).each do |itm| say_private( itm, , token, secret ) end end |
#say_private(to, message, token, secret) ⇒ Object
29 30 31 |
# File 'lib/social-bee/twi.rb', line 29 def say_private( to, , token, secret ) client( token, secret ).( to, ) end |
#say_public(message, token, secret) ⇒ Object
25 26 27 |
# File 'lib/social-bee/twi.rb', line 25 def say_public( , token, secret ) client( token, secret ).update( ) end |