From fb57b27e8a48abcc82810fe476413e8b506cebe6 Mon Sep 17 00:00:00 2001 From: Daniel Cukier Date: Fri, 2 Jul 2010 06:42:59 +0800 Subject: [PATCH] example to list followers and friends sorted by followers count --- examples/friends_followers_rank.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/friends_followers_rank.rb diff --git a/examples/friends_followers_rank.rb b/examples/friends_followers_rank.rb new file mode 100644 index 000000000..b4198e0a3 --- /dev/null +++ b/examples/friends_followers_rank.rb @@ -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}"}