Class: SiteSearch::GoogleSearch
- Inherits:
-
Object
- Object
- SiteSearch::GoogleSearch
- Defined in:
- lib/site_search/google_search.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#start_index ⇒ Object
readonly
Returns the value of attribute start_index.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize(search_engine, query, options = {}) ⇒ GoogleSearch
constructor
A new instance of GoogleSearch.
Constructor Details
#initialize(search_engine, query, options = {}) ⇒ GoogleSearch
Returns a new instance of GoogleSearch.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/site_search/google_search.rb', line 10 def initialize(search_engine, query, ={}) raise NoResults.new if query.blank? @query = escape_html(query).gsub(" ", '+') @results = [] doc = get_document(set_uri(, search_engine.to_s)) @raw = doc.body case [:alt] when 'atom' then parse_atom(doc) else parse_json(doc) end end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
8 9 10 |
# File 'lib/site_search/google_search.rb', line 8 def raw @raw end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
8 9 10 |
# File 'lib/site_search/google_search.rb', line 8 def results @results end |
#start_index ⇒ Object (readonly)
Returns the value of attribute start_index.
8 9 10 |
# File 'lib/site_search/google_search.rb', line 8 def start_index @start_index end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
8 9 10 |
# File 'lib/site_search/google_search.rb', line 8 def total @total end |