Skip to content

Instantly share code, notes, and snippets.

@jamie
Forked from ivey/current.rb
Created August 7, 2008 14:55
Show Gist options
  • Save jamie/4420 to your computer and use it in GitHub Desktop.
Save jamie/4420 to your computer and use it in GitHub Desktop.
refactor iteration to use map
def following_pages
twitter_user.friends_count.to_i / 100 + 1
end
def following
@following ||= (1..following_pages).map do |i|
twitter.friends_for(uid, :page => i, :lite => true)
end.flatten
end
def followers_pages
twitter_user.followers_count.to_i / 100 + 1
end
def followers
@followers ||= (1..followers_pages).map do |i|
twitter.followers_for(uid, :page => i, :lite => true)
end.flatten
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment