Class: Pork::TwitterUser
- Inherits:
-
Object
- Object
- Pork::TwitterUser
- Defined in:
- lib/pork_sandwich/twitter_user.rb
Instance Attribute Summary collapse
-
#crawled ⇒ Object
Returns the value of attribute crawled.
-
#db_object ⇒ Object
Returns the value of attribute db_object.
-
#desired_follower_count ⇒ Object
Returns the value of attribute desired_follower_count.
-
#desired_friend_count ⇒ Object
Returns the value of attribute desired_friend_count.
-
#follower_relationship_db_ids ⇒ Object
readonly
Returns the value of attribute follower_relationship_db_ids.
-
#friend_relationship_db_ids ⇒ Object
readonly
Returns the value of attribute friend_relationship_db_ids.
-
#puller ⇒ Object
Returns the value of attribute puller.
-
#since_tweet_id ⇒ Object
Returns the value of attribute since_tweet_id.
-
#tweet_db_ids ⇒ Object
readonly
Returns the value of attribute tweet_db_ids.
-
#twitter_id ⇒ Object
Returns the value of attribute twitter_id.
-
#twitter_screen_name ⇒ Object
Returns the value of attribute twitter_screen_name.
-
#user_info ⇒ Object
Returns the value of attribute user_info.
Instance Method Summary collapse
- #crawled? ⇒ Boolean
-
#initialize(opts) ⇒ TwitterUser
constructor
A new instance of TwitterUser.
- #pull_account_info ⇒ Object
- #pull_follower_ids ⇒ Object
- #pull_followers ⇒ Object
- #pull_friend_ids ⇒ Object
- #pull_friends ⇒ Object
- #pull_tweets ⇒ Object
- #sanitize_id(id) ⇒ Object
- #search ⇒ Object
- #update_account_info ⇒ Object
Constructor Details
#initialize(opts) ⇒ TwitterUser
Returns a new instance of TwitterUser.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pork_sandwich/twitter_user.rb', line 7 def initialize(opts) @twitter_id = sanitize_id(opts[:twitter_id]) @twitter_screen_name = opts[:twitter_screen_name] @crawled = opts[:crawled] @user_info = opts[:user_info] @db_object = opts[:db_object] @puller = opts[:puller] @tweet_db_ids = nil @follower_relationship_db_ids = nil @friend_relationship_db_ids = nil @desired_follower_count = opts[:desired_follower_count] @desired_friend_count = opts[:desired_friend_count] @since_tweet_id = opts[:since_tweet_id] end |
Instance Attribute Details
#crawled ⇒ Object
Returns the value of attribute crawled.
3 4 5 |
# File 'lib/pork_sandwich/twitter_user.rb', line 3 def crawled @crawled end |
#db_object ⇒ Object
Returns the value of attribute db_object.
3 4 5 |
# File 'lib/pork_sandwich/twitter_user.rb', line 3 def db_object @db_object end |
#desired_follower_count ⇒ Object
Returns the value of attribute desired_follower_count.
3 4 5 |
# File 'lib/pork_sandwich/twitter_user.rb', line 3 def desired_follower_count @desired_follower_count end |
#desired_friend_count ⇒ Object
Returns the value of attribute desired_friend_count.
3 4 5 |
# File 'lib/pork_sandwich/twitter_user.rb', line 3 def desired_friend_count @desired_friend_count end |
#follower_relationship_db_ids ⇒ Object (readonly)
Returns the value of attribute follower_relationship_db_ids.
4 5 6 |
# File 'lib/pork_sandwich/twitter_user.rb', line 4 def follower_relationship_db_ids @follower_relationship_db_ids end |
#friend_relationship_db_ids ⇒ Object (readonly)
Returns the value of attribute friend_relationship_db_ids.
4 5 6 |
# File 'lib/pork_sandwich/twitter_user.rb', line 4 def friend_relationship_db_ids @friend_relationship_db_ids end |
#puller ⇒ Object
Returns the value of attribute puller.
3 4 5 |
# File 'lib/pork_sandwich/twitter_user.rb', line 3 def puller @puller end |
#since_tweet_id ⇒ Object
Returns the value of attribute since_tweet_id.
3 4 5 |
# File 'lib/pork_sandwich/twitter_user.rb', line 3 def since_tweet_id @since_tweet_id end |
#tweet_db_ids ⇒ Object (readonly)
Returns the value of attribute tweet_db_ids.
4 5 6 |
# File 'lib/pork_sandwich/twitter_user.rb', line 4 def tweet_db_ids @tweet_db_ids end |
#twitter_id ⇒ Object
Returns the value of attribute twitter_id.
3 4 5 |
# File 'lib/pork_sandwich/twitter_user.rb', line 3 def twitter_id @twitter_id end |
#twitter_screen_name ⇒ Object
Returns the value of attribute twitter_screen_name.
3 4 5 |
# File 'lib/pork_sandwich/twitter_user.rb', line 3 def twitter_screen_name @twitter_screen_name end |
#user_info ⇒ Object
Returns the value of attribute user_info.
3 4 5 |
# File 'lib/pork_sandwich/twitter_user.rb', line 3 def user_info @user_info end |
Instance Method Details
#crawled? ⇒ Boolean
22 23 24 |
# File 'lib/pork_sandwich/twitter_user.rb', line 22 def crawled? @crawled end |
#pull_account_info ⇒ Object
40 41 42 43 44 |
# File 'lib/pork_sandwich/twitter_user.rb', line 40 def pull_account_info unless @user_info && @db_object self.update_account_info end end |
#pull_follower_ids ⇒ Object
62 63 64 65 |
# File 'lib/pork_sandwich/twitter_user.rb', line 62 def pull_follower_ids pull_result = self.puller.pull(self, &FOLLOWER_IDS) @follower_relationship_db_ids = pull_result[:follower_relationship_db_ids] if pull_result end |
#pull_followers ⇒ Object
52 53 54 55 |
# File 'lib/pork_sandwich/twitter_user.rb', line 52 def pull_followers pull_result = self.puller.pull(self, &FOLLOWERS) @follower_relationship_db_ids = pull_result[:follower_relationship_db_ids] if pull_result end |
#pull_friend_ids ⇒ Object
67 68 69 70 |
# File 'lib/pork_sandwich/twitter_user.rb', line 67 def pull_friend_ids pull_result = self.puller.pull(self, &FRIEND_IDS) @friend_relationship_db_ids = pull_result[:friend_relationship_db_ids] if pull_result end |
#pull_friends ⇒ Object
57 58 59 60 |
# File 'lib/pork_sandwich/twitter_user.rb', line 57 def pull_friends pull_result = self.puller.pull(self, &FRIENDS) @friend_relationship_db_ids = pull_result[:friend_relationship_db_ids] if pull_result end |
#pull_tweets ⇒ Object
34 35 36 37 38 |
# File 'lib/pork_sandwich/twitter_user.rb', line 34 def pull_tweets pull_result = self.puller.pull(self, &TWEETS) @tweet_db_ids = pull_result[:db_ids] if pull_result return true end |
#sanitize_id(id) ⇒ Object
30 31 32 |
# File 'lib/pork_sandwich/twitter_user.rb', line 30 def sanitize_id(id) id.nil? ? nil : id.to_i end |
#search ⇒ Object
26 27 28 |
# File 'lib/pork_sandwich/twitter_user.rb', line 26 def search twitter_id ? twitter_id : twitter_screen_name end |
#update_account_info ⇒ Object
46 47 48 49 50 |
# File 'lib/pork_sandwich/twitter_user.rb', line 46 def update_account_info pull_result = self.puller.pull(self, &ACCOUNT_INFO) @user_info, @db_object, @twitter_id, @twitter_screen_name = pull_result[:pull_data], pull_result[:db_object], pull_result[:db_object].twitter_id, pull_result[:db_object].screen_name if pull_result return true end |