Class: Socialshare::Tweeter

Inherits:
Object
  • Object
show all
Defined in:
lib/socialshare/tweeter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {})
  @consumer_key = options[:consumer_key]
  @consumer_secret = options[:consumer_secret]
  @user_token = options[:token]
  @user_secret = options[:secret]
  @twitter_user = get_twitter_client(options)
end

Instance Attribute Details

#consumer_keyObject

Returns the value of attribute consumer_key.



5
6
7
# File 'lib/socialshare/tweeter.rb', line 5

def consumer_key
  @consumer_key
end

#consumer_secretObject

Returns the value of attribute consumer_secret.



5
6
7
# File 'lib/socialshare/tweeter.rb', line 5

def consumer_secret
  @consumer_secret
end

#twitter_userObject

Returns the value of attribute twitter_user.



5
6
7
# File 'lib/socialshare/tweeter.rb', line 5

def twitter_user
  @twitter_user
end

#user_secretObject

Returns the value of attribute user_secret.



5
6
7
# File 'lib/socialshare/tweeter.rb', line 5

def user_secret
  @user_secret
end

#user_tokenObject

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(options = {})
  begin
    if options[:name]
      self.twitter_user.friends(options[:name])
    elsif options[:id]
      self.twitter_user.friends(options[:id])
    else  
      self.twitter_user.friends
    end
  rescue Exception => e
    return e
  end     
end

#get_twitter_followersObject



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_timelineObject



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_profileObject



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_timelineObject



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