Class: Socialshare::Tweeter
- Inherits:
-
Object
- Object
- Socialshare::Tweeter
- Defined in:
- lib/socialshare/tweeter.rb
Instance Attribute Summary collapse
-
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
-
#consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
-
#twitter_user ⇒ Object
Returns the value of attribute twitter_user.
-
#user_secret ⇒ Object
Returns the value of attribute user_secret.
-
#user_token ⇒ Object
Returns the value of attribute user_token.
Instance Method Summary collapse
- #fetch_tweet_by_id(tweet_id) ⇒ Object
- #fetch_twitter_friends(options = {}) ⇒ Object
- #get_twitter_followers ⇒ Object
- #get_twitter_home_timeline ⇒ Object
- #get_twitter_profile ⇒ Object
-
#initialize(options = {}) ⇒ Tweeter
constructor
A new instance of Tweeter.
- #post(text) ⇒ Object
- #update_profile_background_photo(file_path) ⇒ Object
- #update_profile_photo(file_path) ⇒ Object
- #user_timeline ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Tweeter
Returns a new instance of Tweeter.
7 8 9 10 11 12 13 |
# File 'lib/socialshare/tweeter.rb', line 7 def initialize( = {}) @consumer_key = [:consumer_key] @consumer_secret = [:consumer_secret] @user_token = [:token] @user_secret = [:secret] @twitter_user = get_twitter_client() end |
Instance Attribute Details
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
5 6 7 |
# File 'lib/socialshare/tweeter.rb', line 5 def consumer_key @consumer_key end |
#consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
5 6 7 |
# File 'lib/socialshare/tweeter.rb', line 5 def consumer_secret @consumer_secret end |
#twitter_user ⇒ Object
Returns the value of attribute twitter_user.
5 6 7 |
# File 'lib/socialshare/tweeter.rb', line 5 def twitter_user @twitter_user end |
#user_secret ⇒ Object
Returns the value of attribute user_secret.
5 6 7 |
# File 'lib/socialshare/tweeter.rb', line 5 def user_secret @user_secret end |
#user_token ⇒ Object
Returns the value of attribute user_token.
5 6 7 |
# File 'lib/socialshare/tweeter.rb', line 5 def user_token @user_token end |
Instance Method Details
#fetch_tweet_by_id(tweet_id) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/socialshare/tweeter.rb', line 71 def fetch_tweet_by_id(tweet_id) begin self.twitter_user.status(tweet_id) rescue Exception => e return e end end |
#fetch_twitter_friends(options = {}) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/socialshare/tweeter.rb', line 79 def fetch_twitter_friends( = {}) begin if [:name] self.twitter_user.friends([:name]) elsif [:id] self.twitter_user.friends([:id]) else self.twitter_user.friends end rescue Exception => e return e end end |
#get_twitter_followers ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/socialshare/tweeter.rb', line 63 def get_twitter_followers begin self.twitter_user.followers rescue Exception => e return e end end |
#get_twitter_home_timeline ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/socialshare/tweeter.rb', line 55 def get_twitter_home_timeline begin self.twitter_user.home_timeline rescue Exception => e return e end end |
#get_twitter_profile ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/socialshare/tweeter.rb', line 23 def get_twitter_profile begin self.twitter_user.user rescue Exception => e return e end end |
#post(text) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/socialshare/tweeter.rb', line 15 def post(text) begin self.twitter_user.update(text) rescue Exception => e return e end end |
#update_profile_background_photo(file_path) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/socialshare/tweeter.rb', line 39 def update_profile_background_photo(file_path) begin self.twitter_user.update_profile_background_image(File.open(file_path)) rescue Exception => e return e end end |
#update_profile_photo(file_path) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/socialshare/tweeter.rb', line 31 def update_profile_photo(file_path) begin self.twitter_user.update_profile_image(File.open(file_path)) rescue Exception => e return e end end |
#user_timeline ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/socialshare/tweeter.rb', line 47 def user_timeline begin self.twitter_user.user_timeline rescue Exception => e return e end end |