Sha256: ff6cc46c04dd5f50841972e533cdbc13fb92c07f80a89cf9e5afcad84f9c2700
Contents?: true
Size: 743 Bytes
Versions: 1
Compression:
Stored size: 743 Bytes
Contents
module SearchTerms # Expects to be mixed into an object that responds to: # * fragment: URI parameters after a # # * query: URI parameters afer a ? # * host: URI host module Extractor def search_string case search_engine when :google, :bing, :aol, :duckduckgo query_parameters["q"].first when :yahoo query_parameters["p"].first end end private def search_engine case host when /google\./ :google when /bing\./ :bing when /yahoo\./ :yahoo when /search\.aol\./ :aol when /duckduckgo\./ :duckduckgo end end def query_parameters CGI.parse(query || fragment || "") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
search_terms-0.0.1 | lib/search_terms/extractor.rb |