$ ./google-rocks-sucks-o-meter.rb "DreamHost Rocks"
1:2

Here's mine. It isn't one line either and uses ruby-google[1] which uses
the SOAP interface.

./google-rsom.rb "ruby"
305:112

./google-rsom.rb "dreamhost"
977:14900

-----------------------------------------------------------
#!/usr/bin/env ruby

require 'google'

APIKEY = "+kDTOhVQFHJh9Xy0d+x4gmUh9m183d2J"
WHAT = ARGV[0].nil? ? "ruby" : ARGV[0]

def gcd(a,b);b == 0 ? a : gcd(b, a % b);end       # thanks, euclid!
def ratio(a,b);return "0" if a == 0 or b == 0;d = gcd(a,b);"#{a/d}:#{b/d}";end

g = Google::Search.new(APIKEY)
a = g.search("\"#{WHAT} rocks\"").estimatedTotalResultsCount
b = g.search("\"#{WHAT} sucks\"").estimatedTotalResultsCount
puts ratio(a.to_i,b.to_i)
-----------------------------------------------------------

[1] http://raa.ruby-lang.org/project/ruby-google/

--
Caleb Phillips
IT Specialist
Small White Cube
_______________________________________________
PDXRuby mailing list
[email protected]
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby

Reply via email to