Skip to content

Commit

Permalink
example to list followers and friends sorted by followers count
Browse files Browse the repository at this point in the history
  • Loading branch information
danicuki authored and sferik committed Sep 22, 2010
1 parent 2d1f7ca commit fb57b27
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/friends_followers_rank.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
require 'pp'

config = ConfigStore.new("#{ENV['HOME']}/.twitter")

httpauth = Twitter::HTTPAuth.new(config['email'], config['password'])
base = Twitter::Base.new(httpauth)

puts "Friends List, sorted by followers"
base.friends.sort {|a,b| a.followers_count <=> b.followers_count}.reverse.each {|f| puts "#{f.name} (@#{f.screen_name}) - #{f.followers_count}"}

puts "\n\nFollowers List, sorted by followers"
base.followers.sort {|a,b| a.followers_count <=> b.followers_count}.reverse.each {|f| puts "#{f.name} (@#{f.screen_name}) - #{f.followers_count}"}

0 comments on commit fb57b27

Please sign in to comment.