Skip to content

Commit

Permalink
extracted magic number into constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Shen committed Jul 29, 2008
1 parent 35e3f40 commit 0e91c65
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions auto_follow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#
class AutoFollower

TWITTER_PAGE_SIZE = 100

def initialize(email, password)
@twitter = Twitter::Base.new(email, password)
end
Expand Down Expand Up @@ -46,13 +48,13 @@ def follow(name)

def find_followers(page = 1)
f = @twitter.followers(:lite => true, :page => page).collect { |f| f.screen_name }
return f if f.empty? || f.size < 100
return f if f.empty? || f.size < TWITTER_PAGE_SIZE
f + find_followers(page + 1)
end

def find_friends(page = 1)
f = @twitter.friends(:lite => true, :page => page).collect { |f| f.screen_name }
return f if f.empty? || f.size < 100
return f if f.empty? || f.size < TWITTER_PAGE_SIZE
f + find_friends(page + 1)
end
end

0 comments on commit 0e91c65

Please sign in to comment.