On Thu, Aug 10, 2006, Topher Cyll wrote:
> require 'net/http'; puts "Usage: google_sucks_rocks.rb <term>" and
> return if ARGV.empty?; options = %w(sucks rocks); results = {};
> options.each { |option| results[option] =
> Net::HTTP.get_response(URI.parse("http://www.google.com/search?q=#{ARGV[0]}+#{option}";)).body.match(/of
> about <b>(.*?)<\/b> for/)[1].gsub(/,/,'').to_f }; puts "Ratio of sucks
> to rocks for #{ARGV[0]} is " + ((results['rocks'] > results['sucks'])
> ? "1:#{(results['rocks'] / results['sucks'])}" : "#{(results['sucks']
> / results['rocks'])}:1")

Well geez, I could have done that ;P

Nice work on the ternary, I don't know why I didn't think of that.

Ben
_______________________________________________
PDXRuby mailing list
[email protected]
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby

Reply via email to