-
-
Save jamie/4420 to your computer and use it in GitHub Desktop.
refactor iteration to use map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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