Oh, snap. On 8/10/06, Topher Cyll <[EMAIL PROTECTED]> wrote:
> It's not one lineIt is now. ;-) 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") Who says Perl wins at one liners? -Toph _______________________________________________ PDXRuby mailing list [email protected] IRC: #pdx.rb on irc.freenode.net http://lists.pdxruby.org/mailman/listinfo/pdxruby
_______________________________________________ PDXRuby mailing list [email protected] IRC: #pdx.rb on irc.freenode.net http://lists.pdxruby.org/mailman/listinfo/pdxruby
