Class: Pork::TwitterUser

Inherits:
Object
  • Object
show all
Defined in:
lib/pork_sandwich/twitter_user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#crawledObject

Returns the value of attribute crawled.



3
4
5
# File 'lib/pork_sandwich/twitter_user.rb', line 3

def crawled
  @crawled
end

#db_objectObject

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_countObject

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_countObject

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_idsObject (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_idsObject (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

#pullerObject

Returns the value of attribute puller.



3
4
5
# File 'lib/pork_sandwich/twitter_user.rb', line 3

def puller
  @puller
end

#since_tweet_idObject

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_idsObject (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_idObject

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_nameObject

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_infoObject

Returns the value of attribute user_info.



3
4
5
# File 'lib/pork_sandwich/twitter_user.rb', line 3

def 
  @user_info
end

Instance Method Details

#crawled?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/pork_sandwich/twitter_user.rb', line 22

def crawled?
  @crawled
end

#pull_account_infoObject



40
41
42
43
44
# File 'lib/pork_sandwich/twitter_user.rb', line 40

def 
  unless @user_info && @db_object
    self.
  end
end

#pull_follower_idsObject



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_followersObject



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_idsObject



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_friendsObject



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_tweetsObject



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

#searchObject



26
27
28
# File 'lib/pork_sandwich/twitter_user.rb', line 26

def search
  twitter_id ? twitter_id : twitter_screen_name    
end

#update_account_infoObject



46
47
48
49
50
# File 'lib/pork_sandwich/twitter_user.rb', line 46

def 
  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