Class: GSA::Result
- Inherits:
-
Object
- Object
- GSA::Result
- Defined in:
- lib/bcms_google_mini_search/gsa.rb
Overview
Represents a single result (aka Hit) from a GSA query. Defined by code.google.com/apis/searchappliance/documentation/46/xml_reference.html#results_xml_tag_r
Instance Attribute Summary collapse
-
#cache_id ⇒ Object
Returns the value of attribute cache_id.
-
#description ⇒ Object
Returns the value of attribute description.
-
#number ⇒ Object
Returns the value of attribute number.
-
#results ⇒ Object
Returns the value of attribute results.
-
#size ⇒ Object
Returns the value of attribute size.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#cached_document_param ⇒ Object
Returns the value for q if a user wants to request the cached version of this document.
- #cached_document_url(gsa_query) ⇒ Object
-
#initialize(xml_element = nil) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(xml_element = nil) ⇒ Result
Returns a new instance of Result.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/bcms_google_mini_search/gsa.rb', line 112 def initialize(xml_element = nil) return if xml_element == nil self.number = xml_element.attributes["N"] self.title = xml_element.elements["T"].try(:text) self.url = xml_element.elements["U"].try(:text) self.description = xml_element.elements["S"].try(:text) cache_element = xml_element.elements["HAS/C"] if cache_element self.size = cache_element.attributes["SZ"] self.cache_id = cache_element.attributes["CID"] else self.size = "" self.cache_id="" end end |
Instance Attribute Details
#cache_id ⇒ Object
Returns the value of attribute cache_id.
109 110 111 |
# File 'lib/bcms_google_mini_search/gsa.rb', line 109 def cache_id @cache_id end |
#description ⇒ Object
Returns the value of attribute description.
109 110 111 |
# File 'lib/bcms_google_mini_search/gsa.rb', line 109 def description @description end |
#number ⇒ Object
Returns the value of attribute number.
109 110 111 |
# File 'lib/bcms_google_mini_search/gsa.rb', line 109 def number @number end |
#results ⇒ Object
Returns the value of attribute results.
109 110 111 |
# File 'lib/bcms_google_mini_search/gsa.rb', line 109 def results @results end |
#size ⇒ Object
Returns the value of attribute size.
109 110 111 |
# File 'lib/bcms_google_mini_search/gsa.rb', line 109 def size @size end |
#title ⇒ Object
Returns the value of attribute title.
109 110 111 |
# File 'lib/bcms_google_mini_search/gsa.rb', line 109 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
109 110 111 |
# File 'lib/bcms_google_mini_search/gsa.rb', line 109 def url @url end |
Instance Method Details
#cached_document_param ⇒ Object
Returns the value for q if a user wants to request the cached version of this document.
132 133 134 135 136 137 138 |
# File 'lib/bcms_google_mini_search/gsa.rb', line 132 def cached_document_param param = "cache:#{cache_id}:#{url}" if results param += "+#{results.query}" end param end |
#cached_document_url(gsa_query) ⇒ Object
140 141 142 |
# File 'lib/bcms_google_mini_search/gsa.rb', line 140 def cached_document_url(gsa_query) SearchResult.query_url(cached_document_param, {:host=>gsa_query.engine.host, :collection=>gsa_query.collection, :front_end=>gsa_query.front_end, :as_xml=>false}) end |