Module: UtilityBelt::Google

Included in:
Object
Defined in:
lib/utility_belt/google.rb

Instance Method Summary collapse

Instance Method Details

#google(search_term = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/utility_belt/google.rb', line 9

def google(search_term = nil)
  search_term ||= Clipboard.read if Clipboard.available?
  if search_term.empty?
    puts "Usage: google search_term_without_spaces           (Unix command line only)"
    puts "       google 'search term with spaces'            (Unix or IRB)"
    puts "       google                                      (Unix or IRB)"
    puts "              (if invoking without args, must have text in clipboard)"
  else
    url = "http://google.com/search?q=#{CGI.escape(search_term)}"
    WebBrowser.open(url)
  end
end